Reputation: 143
Hello Experts I need help
I'm using dojo Dijit Editor
"rich text editor" field in my widget, on page load I fetch HTML text from database and I set the rich text editor with the HTML normally, Then user can edit the displayed text and on page close I have to set the field in database with the source HTML of the edited text by user
the problem is when I do the following "myDB_txt=myEditor.getValue()
;" getValue()
doesn't return the complete HTML code it removes HTML tag and header tag and body tag which causes me troubles.
Upvotes: 0
Views: 431
Reputation: 73918
You could try the following to retrieve the value from your dijit/Editor
instance.
var content = myEditor.attr("value");
var openTags = '<html><head></head><body>';
var closeTags = '</body></html>';
var html = openTags + content + closeTags; // use this
or
var htmlWrapper = function(content){
return '<html><head></head><body>' + content + '</body></html>';
};
var html = htmlWrapper(myEditor.attr("value"));
Upvotes: 0
Reputation: 14712
Simply use myEditorWidget.get("Value")
where myEditorWidget refer to your dijit/Editor
indtance
To wrap this result you can define a function that return result wraped by html tags
wrapResult(myEditor.get("value")));
function wrapResult(html) {
return "<html> <head></head> <body>"+html+"</body></html>";
}
Here is a Sample with wraped result Fiddle .
Otherwise If you want to get the whole HTML enclosing the content dijit ,
you will get access to it's Iframe
( that has the id="editor_iframe"
)
and then get get the html document
of this last like bellow (here you should import dojo/query
package)
query("#editor_iframe")[0].contentDocument.documentElement.outerHTML
Here is another Fiddle .
Upvotes: 1