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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With