Dojo widget description line is a temporary thing?

I'm wondering if this is a temporary thing ("my.example.Widget") now that AMD is on stage or is it?

declare('my.example.Widget', [], {

});

      

If I have a widget defined above, how can I check the widget type? Is there a way to do this that works with AMD?

+3


source to share


1 answer


To check if a Dijit widget actually inherits from a specific widget or Mixin, use the function isInstanceOf

like this:

var Widget = declare([_WidgetBase], {
     name: "Widget_Name",
     id: "some_id"
});
var widgetInstance = new Widget();
console.log(widgetInstance.isInstanceOf(Widget)); // True
console.log(widgetInstance.isInstanceOf(_WidgetBase)); // True
console.log(widgetInstance.isInstanceOf(_TemplatedMixin)); // False

      



You can see it in action from this jsfiddle .

+1


source







All Articles