tsailipu
09-01-2005, 04:51 PM
I saw some topics on disabling tab and selecting the previous one and some replies by Pablo (e.g. see the thread titled "Accessing tabs from code" ). But a search on "select a tab" didn't return any result. Seeing posts about how tabpane is missing some default events such as onselected, onclick, etc. and the post about the default set of tabs related components are just missing those events (see "Tabpane: I need an event to fire on select or click"), I guess for 3.0 or 3.0.2 in order to do this, I would have to look into the internals of how tabs, tabsbar, tabpane and tab work.
So I find a solution and am sharing here:
Basically, you can do:
"tabs".subviews[0].subviews["i"].setAttribute('click', true)
, where "tabs" is the name/id of your tabs/basetabs and "i" is the index number of the tabs you want to select/click programmatically. (The subviews[0] gets the tabsbar/basetabsbar member of the tabs/basetabs, which contains a list of tabs/basetabs.)
But, boy, isn't doing this non-intuitive and rather hacky (basically defeating the the purpose of black box/object encapsulation) for a behavior that we would expect from the out-of-box Laszlo tabs/tabspane/tab component? Is there a better way/cleaner way to do such? Or is Laszlo 3.1 providing such enhancement? If not, has anyone filed a feature request on this? Something like:
"tabs".[select|click]("tabpane_name"|"tabpane_id");
would have been great. (I guess there can be a set of utility methods like this, such as "hide"/"show", "enable"/"disable" a particular tab.)
Cheers,
Philip
So I find a solution and am sharing here:
Basically, you can do:
"tabs".subviews[0].subviews["i"].setAttribute('click', true)
, where "tabs" is the name/id of your tabs/basetabs and "i" is the index number of the tabs you want to select/click programmatically. (The subviews[0] gets the tabsbar/basetabsbar member of the tabs/basetabs, which contains a list of tabs/basetabs.)
But, boy, isn't doing this non-intuitive and rather hacky (basically defeating the the purpose of black box/object encapsulation) for a behavior that we would expect from the out-of-box Laszlo tabs/tabspane/tab component? Is there a better way/cleaner way to do such? Or is Laszlo 3.1 providing such enhancement? If not, has anyone filed a feature request on this? Something like:
"tabs".[select|click]("tabpane_name"|"tabpane_id");
would have been great. (I guess there can be a set of utility methods like this, such as "hide"/"show", "enable"/"disable" a particular tab.)
Cheers,
Philip