最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - query list of dijit checkboxes inside a DIV - Stack Overflow

programmeradmin1浏览0评论

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

发布评论

评论列表(0)

  1. 暂无评论