Skip to content

Set the selected status of an action bar item without invoke the onClick hook defined for the item #770

xqliu opened this Issue Mar 28, 2013 · 3 comments

2 participants

xqliu commented Mar 28, 2013

Dear All,

I meet an requirement that I would like to set the selected status of an action bar item without invoke the onClick hook defined for the item,

I remember we have a discussion before, for example #598.

Is there any plan to implement this or this there any workaround we could use to implement this?


xqliu commented Mar 28, 2013

I am wondering whether we could add the second boolean parameter to indicate whether the onclick need to be invoked. Here are what I have changed in bbui.js, is it possible that we merge this tiny change to current stream to support this?

        actionBar.setSelectedTab = function(tab, invokeOnClick) {
                    if (tab.getAttribute('data-bb-style') != 'tab') return;
                    if (tab.onclick && true === invokeOnClick) {
Open Source Projects member
tneil commented Mar 28, 2013

There are a couple of solutions to this.

1) If you are looking to set the state of the tab before the screen is shown to the user you can set the data-bb-selected="true" attribute in the onscreenready event. This will draw the tab selected but not fire its onclick.

2) If you need to set the selected state of the tab without the onclick firing after the DOM has been loaded I would suggest the following.

First set your own flag on the tab you want to select and .

var tab = document.getElementById('myTab'),
    actionBar = document.getElementById('myActionBar');

tab.ignoreclick = true;

Then in the onclick of your tab check to see if you have set your flag. If you have then return from the event

function myclick() {
   if (this.ignoreclick == true) {
      this.ignoreclick = false;

  // My normal onclick function stuff
xqliu commented Mar 28, 2013
@tneil tneil closed this Mar 28, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.