gregory561
gregory561

Reputation: 15046

Adding a dijit.Editor dynamical onClick

I want to add dijit.Editor after clicking on element.

    dojo.ready( function() {
    var handle = dojo.connect(dojo.byId("k"),"onclick", 
        function(){
            dojo.byId("k").innerHTML += 
                "<div data-dojo-type=\"dijit.Editor\" id=\"editor\" style=\"width:400px;min-height:100px;background-color:white;border-style:solid;border-width:1px\" > </div>";
                 dojo.disconnect(handle);
        }
    );
}); 

In general this code works but dijit.Editor is malformed, one cannot write in it and there are no default plugins. How can I fix this?

Upvotes: 1

Views: 252

Answers (3)

user2161206
user2161206

Reputation: 1

<script>function(ready, Editor, AlwaysShowToolbar, dom, query){
this.createEditor = function(){
    new Editor({
        height: '40px',},dom.byId('programmatic2'));autosave:false,
    query('#create2').orphan();

}
});

</script>

try this.. u might get a solution..

Upvotes: -1

PEM
PEM

Reputation: 1978

I believe inlineEditBox is better fit to your need. Also more generally, you add declarative code, in an onClick, after dojo.ready. Basically it means that the html is "probably" parsed, then you get dojo.ready, do your connect, when the onClick happens, you add declarative markup in your html code, but you are not calling the parser.

I would recommand using programmatic approach for these kind of cases and keep declarative for templated widgets, or html string you will "parse" calling the parser.

Hope this also helps a little ;)

Upvotes: 1

Philippe
Philippe

Reputation: 6828

Is this for inline editing ? Because if so, you should follow the examples on this page.

Othewise, you should do something like this rather than creating html in javascript.

Upvotes: 2

Related Questions