Robert Johnstone
Robert Johnstone

Reputation: 5371

Setting dijit.editor content

How can I set the content of a dijit.editor after it has loaded?

The following is a solution but I am using <script type='dojo/method'> a lot because crome and opera don't like dojo.connect(nodeId, 'onclick', function(){ ... }); (though firefox seems happy). I tried <script type="dojo/method" event="onLoadDeferred"> but it just threw up an error.

Any ideas?

EDIT

If you can't load content into an editor how are you surposed to used it to update content?

Upvotes: 0

Views: 3210

Answers (1)

BuffaloBuffalo
BuffaloBuffalo

Reputation: 7852

This might be a stupid answer, but have you simply tried putting the value inside the declaration of the dijit.Editor?

For example:

<body class="claro">
    <div data-dojo-type="dijit.Editor" id="myEditor">
        This is the initial value of the editor
    </div>
</body>

This will create the editor and set the value of the editor to be whatever text is inside the dijit.Editor markup ("This is the initial value of the editor").

If you need to programmatically change the value of the editor AFTER it has loaded, it seems like you can just use editor.set('value', 'some new text');

For example:

<body class="claro">
    <div data-dojo-type="dijit.Editor" id="myEditor">
        This is the initial value of the editor
    </div>

    <div data-dojo-type="dijit.form.Button">
      Click to change editor value
       <script type="dojo/method" event="onClick">
           var editor = dijit.byId('myEditor');
           editor.set('value','this is the new value');
        </script>
    </div>
</body>

I put together the working sample above in a jsfiddle

http://jsfiddle.net/Vu4NF/1/

Upvotes: 1

Related Questions