Question

I created a Icon menu on my first swap view with multiple IconMenuItems. This is a snipet of the code. How do I manipulate the individual IconMenutItems from the JS file? I tried both retrievals of the first IconMenutItem resulting in the retrieval of a [object HTMLLIElement] instead of the IconMenuItem. Even with a call to the button.label or button.title it came back as undefined. Is it possible to manipulate a specific dojo item after it is created? Sorry if this is a beginner question, I am very new to both Worklight and Dojo

HTML:

    <div data-dojo-type="dojox.mobile.SwapView"id="MainPageView"
    data-dojo-props="selected:true">
        <ul data-dojo-type="dojox.mobile.IconMenu" id="menu"
        style="width: 320px; height: 400px;" data-dojo-props="cols: 3">
            <li data-dojo-type="dojox.mobile.IconMenuItem"label="empty"
            onclick=handleButton(this) id="btn1" title="title1"></li>
        </ul>
    </div>

JS:

    var button1= document.getElementById("btn1");
    WL.Logger.debug(""+button1.label);

    var button2= dojo.query("#btn1");
    WL.Logger.debug(""+button2.label);*
Was it helpful?

Solution

Use the dijit/registry

require(['dijit/registry'], function(registry) {
    var btn1 = registry.byId("btn1");
});

Here's a fiddle: http://jsfiddle.net/cswing/GyzXG/

http://dojotoolkit.org/reference-guide/1.9/dijit/registry.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top