Dojo

Overriding _setDisabledAttr

I created a custom widget (widgetA) and in widgetA I override the set disabled function as follows.

_setDisabledAttr: function(value){
   this.inherited(arguments);
   this.someOtherFunction();
}

However, setting disabled to true and then calling widgetA.get(‘disabled’) always returns false.

Without seeing more of the widget code it is difficult to troubleshoot. What is being passed in as the value? What dependencies are included in the custom widget?

It inherits from _WidgetBase, _TemplatedMixin and _WidgetsInTemplateMixin.
This widget basically creates two datetextboxes and links them together (date range from-to). _setDisabledAttr function is something like this:

this.inherited(arguments);
this.dateFrom.set('disabled', value);
this.dateTo.set('disabled', value);

Value is being passed to the function either as true or false.

We expected that calling widgetA.get(‘disabled’) will return the correct value.

None of _WidgetBase, _TemplatedMixin and _WidgetsInTemplateMixin support being ‘disabled’. If you read the code for these you won’t see a _setDisabledAtt function. Things like form dijits do. So in your widget you’re going to need to do something like

isDisabled: false,

_setDisabledAttr: function(disable){
   this.isDisabled = disable;
   this.doStuff();
},

_getDisabledAttr: function(value){
   return this.isDisabled;
}

Or you could inherit from or mixin one of the Form base classes/mixins such as dijit/form/_FormWidget or dijit/form/_FormValueWidget.