Created
July 3, 2014 19:10
-
-
Save jacksonhoose/7b0cfcf66b490d65626e to your computer and use it in GitHub Desktop.
checkbox toggle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var checkBoxToggle = { | |
init: function() { | |
this.checkBoxes = $('#showUnread, #showArchived'); | |
this.tableBodies = $('div.dashboard-table tbody'); | |
this.bindChange(); | |
}, | |
bindChange: function() { | |
this.checkBoxes.on('change', this.changeEvent.bind(this)); | |
}, | |
changeEvent: function(e) { | |
var checked = this.checkBoxes.filter(':checked'); | |
var classes = []; | |
this.tableBodies.show(); | |
if(checked.length) { | |
$.each(checked, function() { | |
classes.push('.' + $(this).attr('id').split('show').pop().toLowerCase()); | |
}); | |
this.tableBodies.not($(classes.join(', '))).hide(); | |
} | |
} | |
}; | |
checkBoxToggle.init(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment