Shailesh Kumar
Shailesh Kumar

Reputation: 6977

query list of dijit checkboxes inside a DIV

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?

Upvotes: 5

Views: 3474

Answers (2)

jimSampica
jimSampica

Reputation: 12420

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(...)

Upvotes: 0

Maine
Maine

Reputation: 1878

Try dijit.findWidgets:

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

Upvotes: 9

Related Questions