Ticket #5601 (new enhancement)
TabContainer: cannot disable tab buttons programatically
| Reported by: | ptwobrussell | Owned by: | bill |
|---|---|---|---|
| Priority: | normal | Milestone: | future |
| Component: | Dijit | Version: | 1.0 |
| Severity: | normal | Keywords: | |
| Cc: | ptwobrussell@… |
Description (last modified by bill) (diff)
As of r12021, I noticed that it was not possible to disable a tab programatically via the setDisabled(true) or setAttribute('disabled', true). To verify, I ran this code on the test page with all of the various tab containers:
dijit.registry.byClass("dijit.layout._TabButton").forEach(function(x) {x.setAttribute('disabled',true);});
wildbill noticed that in _TabButton.html, there is a connection that is not set up properly. The onclick:onClick part of the outermost dojoAttachEvent should actually be onclick:_onClick
So. With that fix in place, you can disable a tab using the original piece of code above. i.e. find the tab button by iterating over the registry and filtering it out. i.e.
var b;
dijit.registry.byClass("dijit.layout._TabButton").forEach(function(x) {if (x.label=="your tab button's label") b = x;});
//now disable it...
b.setAttribute('disabled', true);
Maybe there are cleaner ways of getting it done, but that one was the most obvious one to me.
At any rate, I think a great feature for a future release would be the ability to disable tab buttons a lot easier. It seems like something that's not an uncommon use case.