开发者

Setting dijit.editor content

开发者 https://www.devze.com 2023-04-04 11:14 出处:网络
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=\'开发者_JAVA技巧dojo/method\'> a lot because crome and opera don\'t lik

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='开发者_JAVA技巧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?


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/

0

精彩评论

暂无评论...
验证码 换一张
取 消