partoa / ui.tabs.closable

Closable Tabs for jQuery UI

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Closable Tabs for jQuery UI

An unobtrusive way to add a close button to jQuery UI tabs.

Demo

Demo of the close button functionality at http://andrew.io/playpen/ui.tabs.closable/demo/

How To Use

  1. Follow the instructions on the jQuery UI Tabs site and include the necessary jQuery and jQuery UI files. Then read through the overview at the jQuery UI Tabs site to get an idea of what is possible.

  2. Include the javascript file in your html file or js loader. eg:

     <script type="text/javascript" src="ui.tabs.closable.min.js"></script>
    
  3. add a closable option when instatiating the tabs:

     $('#tabs').tabs({closable: true})
    
  4. (optional) If you wish to receive a callback when the close button is clicked you can add a closableClick function to the tab options:

     $('#tabs').tabs({
         closable: true,
         closableClick: function(event, ui) {
             // return true to allow the remove of the tab
             // return false to prevent the remove
         }
     });
    
  5. (optional) To set some not closable tabs just add class="tab-notclosable" class to the <li> element

     <div id="tabs">
         <ul>
             <li class="tab-notclosable"><a href="#my-notclosable-tab">My Tab</a></li>
         </ul>
         <div id="my-notclosable"></div>
     </div>
    

That's it, about as unobtrusive as I could make it.

About

Closable Tabs for jQuery UI

License:GNU General Public License v2.0


Languages

Language:JavaScript 100.0%