0leg
0leg

Reputation: 14144

data-dojo-attach-point class-lie analog

One uses data-dojo-attach-point as a unique identifier (analog of ID) in order to access particular widget-element inside particular instance of the widget.

Is there any class-like analog one could use?

For example there is a widget Foo and its instances Foo1, Foo2, Foo3 etc. And each Foo has 10 Dijit/Form/TextBox elements and a button.

The aim is to change all 10 buttons with 1 line of code. One would simply add a class to each of 10 elements and use Dojo/Query to access each of them.

or

Is it possible to add class to a widgets (Diji/Form/TextBox) (not its DomNode). So when one uses Dojo/Query - it would list all elements of the current instance of the widget.

Upvotes: 0

Views: 302

Answers (2)

mannyyysh
mannyyysh

Reputation: 339

yes you can attach the class to widget there are many ways

  1. have a baseClass attribute in the widget, that will automatically attach it to the widget created and you can query on that class

baseclass:'someWidgetClass';

  1. you can assign css class using data-dojo-props to the widget in the widget

data-dojo-props="class:'someWidgetClass'

Upvotes: 1

Allen Wallace
Allen Wallace

Reputation: 121

OK give each Foo widget a unique html id (ex. #Foo1), this will override the auto-generated ID done by Dijit. Next give each TextBox widget within the Foo widget a class="Foo_TB". Then you can use dojo.query("#Foo1 .Foo_TB'"); to return all the TextBox widgets in Foo1.

Upvotes: 1

Related Questions