Ticket #5601 (new enhancement)

Opened 10 months ago

Last modified 4 months ago

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.

Change History

Changed 10 months ago by bill

(In [12049]) Call _onClick() rather than onClick() so that disabled tabs don't do anything. Still need to change CSS so disabled tabs look disabled, and have better way of disabling tabs then mucking with internal structures. Refs #5601.

Changed 10 months ago by bill

  • milestone changed from 1.0.3 to 1.2

We obviously need a better way to disable a tab button, as it's hard to find which button is associated with which tab panel. I guess you can just search for the label, but that's not ideal.

Also, there's a philosophical issue about whether you are disabling the button or the pane. It doesn't make a difference except for StackContainer? where there can be two StackControllers? (with the buttons), both pointing to the same StackContainer? (with the panes).

Changed 9 months ago by bill

  • summary changed from Cannot disable tab buttons programatically to TabContainer: cannot disable tab buttons programatically

Changed 4 months ago by bill

  • type changed from defect to enhancement
  • description modified (diff)
  • milestone changed from 1.2 to future
Note: See TracTickets for help on using tickets.