admin管理员组

文章数量:1309955

I need to find all dijit.form.CheckBox widgets inside a DIV and enable/disable them all. I am not able to form appropriate query for it.

I tried dojo.query("[dojoType~=dijit.form.CheckBox]") but it gives me an empty list.

What is the appropriate query for it? Can DOJO query return a WidgetSet or does it always returns DOM ids? Is there some different way for querying dijit widgets?

I need to find all dijit.form.CheckBox widgets inside a DIV and enable/disable them all. I am not able to form appropriate query for it.

I tried dojo.query("[dojoType~=dijit.form.CheckBox]") but it gives me an empty list.

What is the appropriate query for it? Can DOJO query return a WidgetSet or does it always returns DOM ids? Is there some different way for querying dijit widgets?

Share Improve this question asked Dec 11, 2009 at 8:38 Shailesh KumarShailesh Kumar 6,9778 gold badges37 silver badges60 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 9

Try dijit.findWidgets:

Search subtree under root, putting found widgets in outAry. Doesn't search for nested widgets (ie, widgets inside other widgets)

This is 1.7 > code and will search recursively for widgets instead of just direct descendents as is the case for findWidgets

need to require "dojo/query" and optionally "dijit/registry"

var checkboxes = query("input[type=checkbox]:checked", "myForm");
checkboxes.forEach((function (checkbox) {
    //dom node
    console.log(checkbox);

    //dijit
    console.log(registry.byId(checkbox.id));
})); 

This queries checked checkboxes underneath a dom node id myForm and loops through the results and prints the element. Note that this only gives dom node elements in the result set so if you want to get the dijits you can use registry.byId(...)

本文标签: javascriptquery list of dijit checkboxes inside a DIVStack Overflow