Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dojo widget declaration string - is it a temporary thing?

I'm wondering if this is a temporary thing ('my.example.Widget') now that AMD is on the scene, or is it there to be?

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

});

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

like image 612
Alex Avatar asked Jun 09 '26 01:06

Alex


1 Answers

The way to check if your Dijit widget inherits from a specific Widget or Mixin is to use the isInstanceOf function as follows:

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 with this jsfiddle.

like image 151
Default Avatar answered Jun 11 '26 21:06

Default



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!