$(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);
});
});
|