2

I have a jQuery UI tab control in my web page, and i want to make an "Add Tab" button having the same look than the tab titles (and located in the "tab bar", with other tab titles). I added an item in the list, with a specific class allowing me to make it float on the right. But I cannot remove the default action added by jQuery (on click, open related tab), which leads to an error, because the tab doesn't exist.

I tried several methods :

  • Disabling the tab makes it fade on the screen (removing the css I want)
  • Using unbind does not remove the onClick listener.
  • Setting another onClick listener does not work either, as it is simply ignored...

I'm losing my mind on this. Anyone can help me stay sane ?

2 Answers 2

1

You could use the select event and catch the event when clicked on your tab. In there you could make a new tab and give that focus.

Sign up to request clarification or add additional context in comments.

Comments

1

As Jerone pointed out, the select event is your friend.

Set the url of your 'Add' tab to "#Add" (Or some other value that can be used to uniquely identify that tab) Inside the event handler, check the value of ui.tab.hash, to check if this hash value is present and , if so, create the new tab, select it, and return 'false'. If the hash value doesn't match you magic value, then return 'true', to let the tab selection process continue as normal.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.