Skip to content

Instantly share code, notes, and snippets.

@zanematthew
Created January 16, 2012 15:41
Show Gist options
  • Save zanematthew/1621437 to your computer and use it in GitHub Desktop.
Save zanematthew/1621437 to your computer and use it in GitHub Desktop.
Temp
jQuery(document).ready(function( $ ){
$("a.toggle_handle").on( "click", function( event ){
event.preventDefault
items = $( this ).attr("data-items");
$( "tr." + items ).toggle();
});
$(".item_handle").on("click", function( event ){
taxonomy = $(this).attr('data-taxonomy');
term = $(this).val();
var terms = [];
$(':checked').each(function(){
terms.push( $(this).val() );
});
$('tr.'+taxonomy).find('input:first').val( terms );
});
$('.check_all').on('click', 'input:checkbox', function() {
$('input.'+$(this).attr('data-taxonomy')).each(function() {
taxonomy = $(this).attr('data-taxonomy');
term = $(this).val();
var terms = [];
$(':checked').each(function(){
// Don't put out 'check_all', in the array statck
if ( $(this).attr('data-key') != 'true' ) {
terms.push( $(this).val() );
}
});
// Find our first input field and add our terms
$('tr.'+taxonomy).find('input:first').val( terms );
$(this).attr('checked', !$(this).attr('checked') );
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment