Skip to content

Instantly share code, notes, and snippets.

@robertbasic
Created February 6, 2012 17:03
Show Gist options
  • Select an option

  • Save robertbasic/1753335 to your computer and use it in GitHub Desktop.

Select an option

Save robertbasic/1753335 to your computer and use it in GitHub Desktop.
Dojo Editor
define([
'dojo/query',
'dojo/dom-construct',
'dojo/dom-attr',
'dijit/Editor',
"dijit/_editor/plugins/LinkDialog",
"dijit/_editor/plugins/ViewSource"
],
function(query, construct, attr, Editor) {
var editors = query(".dojoed-form textarea.dojo-editor");
editors.forEach(function(editor) {
var name = attr.get(editor, 'name');
var value = attr.get(editor, 'value');
var div = construct.create(
"div",
{
innerHTML: value,
className: 'dojo-editor-holder'
},
editor,
"after"
);
var hidden = construct.create(
"input",
{
type: 'hidden',
name: name,
id: name,
value: value
},
editor,
"after"
);
new Editor({
height: 'auto',
plugins: ['bold', 'italic', '|', 'insertUnorderedList', 'insertOrderedList'],
extraPlugins:['createLink','insertImage','|','viewsource'],
onChange: function(value) {
attr.set(name, 'value', value.replace(/<br \/>$/, ''));
}
}, div);
construct.destroy(editor);
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment