dojo - domAttr.set(item, 'onclick', 'function(myObject)') doesn't work -
I would like to set the
Similarly:
items = domConstruct.create ('li'); DomAttr.set (item, 'internal HTML', structure.label); DomAttr.set (item, 'onClick', 'this.myfunction (' + + + structure + ')');
The problem is:
syntax error: missing] after element list it. Myfunction ([object object])
I know that it works with instructions:
items = domConstruct.create ('li') ; DomAttr.set (item, 'internal HTML', structure.label); DomAttr.set (item, 'onClick', this.myfunction (structure));
But this method executes myfunction
without clicking on an item.
I just execute the code in the item ( li
) and then myFunction ()
, but the function requires an argument.
Edit:
Thank you very much for your reply but I have already tried this way, it also does not work.
There is no error, but my AM is not on 'Li'. In the HTML console, what I'm looking for is: & lt; Li> Lien1 & LT; / Li>
With this code:
domAttr.set (item, 'onClick', function () {this.myfunction (structure);});
So when I click on my label 'Lin 1', nothing happens. Probably because there is no onClick feature.
This is the only problem with Lang and
I think it's only a small thing to change to work ...
Thanks again for your help.
You have to use dojo, then it will work
Item = domConstruct.create ('li'); (Item, 'click', lang.hitch (this, function) {this.myfunction (structure);}));
You have to use more and Lang, and then it
items = domConstruct.create (with '') '); Childitem = domConstruct.create ('a', null, item);
Now you have both options, or you do this (childitem, 'click', lang.hitch this, work () {this.myfunction (structure);}));
or
domAttr.set (childitem, 'onClick', 'This.myfunction (' + + + structure + ')');
Comments
Post a Comment