We can use dojo.query to get certain elements based of CSS selectors but how do we query on object types?
For example, get all the TextBox elements on the page and then use dojo.connect to bind a function?
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- Keeping track of variable instances
- Can php detect if javascript is on or not?
This is not completely supported, yet there are two ways of doing it as i see it.
One, figure out which is the unique class for a TextBox (
.dijitTextBox
), calldojo.query('.dijitTextBox')
, loop resultdojo.forEach
and get the widget withdijit.getEnclosingWidget(domnode)
Or two, loop the
dijit.registry._hash
, testdeclaredClass
, if itsdijit.form.TextBox
- connect.Depending your setup, choose the most efficient one. The latter is commonly best - unless you have 100's of widgets in your page. The first will have to xpath all your elements of the page. Allthough, remember that dojo.query takes a second parameter as 'parentNode'