Skip to content

Instantly share code, notes, and snippets.

@brettsmason
Last active August 29, 2015 14:27
Show Gist options
  • Save brettsmason/8737ca49ec49b2a306d1 to your computer and use it in GitHub Desktop.
Save brettsmason/8737ca49ec49b2a306d1 to your computer and use it in GitHub Desktop.
jQuery( document ).ready( function($) {
$( '.customize-control-checkbox-multiple > ul' ).sortable({
handle: '.dashicons-menu',
axis: 'y',
stop: function( event, ui ) {
checkbox_values = $( this ).parents( '.customize-control' ).find( 'input[type="checkbox"]:checked' ).map(
function() {
return this.value;
}
).get().join( ',' );
$( this ).parents( '.customize-control' ).find( 'input[type="text"]' ).val( checkbox_values ).trigger( 'change' );
}
});
/* === Checkbox Multiple Control === */
$( '.customize-control-checkbox-multiple input[type="checkbox"]' ).on(
'change',
function() {
checkbox_values = $( this ).parents( '.customize-control' ).find( 'input[type="checkbox"]:checked' ).map(
function() {
return this.value;
}
).get().join( ',' );
$( this ).parents( '.customize-control' ).find( 'input[type="checkbox"]' ).val( checkbox_values ).trigger( 'change' );
}
);
} ); // $( document ).ready
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment