Permalink
Browse files

Trigger a custom event on Tab selection, so that the JS behavior can …

…be extended.
  • Loading branch information...
1 parent a4e0127 commit f2df58a3fe58c9503d6991cbfb29df1df114f3f9 @julien-c committed Mar 27, 2012
Showing with 4 additions and 2 deletions.
  1. +4 −2 admin/js/options-custom.js
@@ -64,14 +64,16 @@ jQuery(document).ready(function($) {
});
if (activetab != '' && $(activetab + '-tab').length ) {
- $(activetab + '-tab').addClass('nav-tab-active');
+ $(activetab + '-tab').addClass('nav-tab-active').trigger('of-tab-active');
}
else {
- $(navTabSelector+':first').addClass('nav-tab-active');
+ $(navTabSelector+':first').addClass('nav-tab-active').trigger('of-tab-active');
}
$(navTabSelector).click(function(evt) {
$(navTabSelector).removeClass('nav-tab-active');
$(this).addClass('nav-tab-active').blur();
+ // Trigger a custom event so that the behavior can be extended:
+ $(this).trigger('of-tab-active');
var clicked_group = $(this).attr('href');
if (typeof(localStorage) != 'undefined' ) {
localStorage.setItem("activetab", $(this).attr('href'));

1 comment on commit f2df58a

You'd need to hook in your own js anyways in order to do something when the trigger fires, so why not just set the trigger there or do a standard $('#my-tab').on('click, do_something() );

Please sign in to comment.