Sponsered Links
Categories
Sponsered Links

Rebinding events

 

First, we should give our handler function a name so that we can use it more than once without repeating ourselves:

$(document).ready(function() {
var toggleStyleSwitcher = function(event) {
if (!$(event.target).is('.button')) {
$('#switcher .button').toggleClass('hidden');
}
};
$('#switcher').bind('click.collapse', toggleStyleSwitcher);
});

 

Now that the function has a name, we can bind it again later without repeating the function definition:
$(document).ready(function() {
var toggleStyleSwitcher = function(event) {
if (!$(event.target).is('.button')) {
$('#switcher .button').toggleClass('hidden');
}
};
$('#switcher').bind('click.collapse', toggleStyleSwitcher);
$('#switcher-narrow, #switcher-large').click(function() {
$('#switcher').unbind('click.collapse');
});
$('#switcher-default').click(function() {
$('#switcher')
.bind('click.collapse', toggleStyleSwitcher);
});
});

 
 
Sponsered Links
Latest Updates
 
All Content of this site is for learning only. We do not warrant the correctness of its content. The risk from using it lies entirely with the user. While using this site, you agree to have read and accepted our terms of use and privacy policy.
Copyright © 2009 JSPSERVLETTUTORIAL.INFO All Right Reserved