You need to add a field and your own function, in this example, I've called it id and setContent()
$scope.property = {
id: 'Make a unique ID here',
setContent: function (content) {
for (var i = 0; i != tinymce.editors.length; i++) {
if (tinymce.editors[i].id == $scope.property.id) {
tinymce.editors[i].setContent(content);
}
}
},
label: 'bodyText',
description: 'Load some stuff here',
view: 'rte',
config: {
editor: {
toolbar: ["code", "undo", "redo", "cut", "styleselect", "bold", "italic", "alignleft", "aligncenter", "alignright", "bullist", "numlist", "link", "umbmediapicker", "umbmacro", "table", "umbembeddialog"],
stylesheets: [],
dimensions: { height: 400, width: 250 }
}
}
};
Then you will need to pass a reference to this rte instance to the code that sets the dropdown list. Its a little hard for me to say exactly how you would do this, you might want to consider an angular service to pass the value across.
HACKY WAY - I DON'T VOUCH THIS WILL WORK AT ALL
Add an Id field to $scope.property like
$scope.property = {
id: 'Make a unique ID here',
label: 'bodyText',
but in your case,. try and give Id a better constant value
Then in the code that sets the dropdown list call
tinymce.get('Make a unique ID here').setContent('This is the content I want');
Hi Dave,
I followed your example too.
It displays content perfectly but how to change RTE inside text.
For example , there is a button below the RTE and if we want to change text of RTE on click of button , then how would we do it ? (This is my requirement)
I used the following code to update but it did not change text of RTE:
$scope.btnUpdate = function ( ) {
$scope.model.rtevalue = "A new text";
}
Umbraco 7 custom RTE with angularjs
I am following this example (Option 2) - http://www.enkelmedia.se/blogg/2013/12/4/umbraco-7-use-the-rich-text-editor-tinymce-in-a-custom-section.aspx
I want to update value of rich text editor on change of dropdown but unable to do so.
I am updating value like this : $scope.myProperty.value = "Test";
This is updating the value of myProperty model but not updating text of rich text editor.
Hi Ariel,
THE PROPER WAY TO DO IT
First part is to add some functionality to your instance of tinymce so that it can set values.
Do you see the bit
You need to add a field and your own function, in this example, I've called it id and setContent()
Then you will need to pass a reference to this rte instance to the code that sets the dropdown list. Its a little hard for me to say exactly how you would do this, you might want to consider an angular service to pass the value across.
HACKY WAY - I DON'T VOUCH THIS WILL WORK AT ALL
Add an Id field to $scope.property like
but in your case,. try and give Id a better constant value
Then in the code that sets the dropdown list call
For further info about tinyMce's setContent()
I hope this helps
Cheers
Jonathan
Hi Jonathan,
Thank you for giving your precious time.
Used your code but i am getting an error on console "Tiny mice is not defined" for this tinymce.get('myId').setContent('This is the content I want').
I think this "tinymce.get().." is used if we are using Jquery tinymce but i am using of angularjs.
Below is my code :
Hi Ariel,
I have tried a different way of displaying the RTE. Read the part of reusing existing datatypes in this article : http://24days.in/umbraco-cms/2014/umbraco-angular-tips/
That worked very well for me
Dave
Hi Dave, I followed your example too. It displays content perfectly but how to change RTE inside text.
For example , there is a button below the RTE and if we want to change text of RTE on click of button , then how would we do it ? (This is my requirement)
I used the following code to update but it did not change text of RTE:
Hi Ariel,
From my code example you should do this :
Dave
Hi Dave,
I wrote this on button's click ,
But this only updated the value of $scope.rteField[0].value , not text of RTE (That is still same as it was before click).
???
Can you post your full code ?
is working on a reply...