Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
//Based http://www.ilovecolors.com.ar/preserving-radio-button-checked-state-during-drag-and-drop-jquery/
$('#example').sortable({
(...)
start: function (e, ui) {
var radio_checked= {};
me.$el.find('input[type="radio"]', this).each(function(){
if($(this).is(':checked'))
radio_checked[$(this).attr('name')] = $(this).val();
$(document).data('radio_checked', radio_checked);
});
}
}).bind('sortstop', function (event, ui) {
var radio_restore = $(document).data('radio_checked');
$.each(radio_restore, function(index, value){
$('input[name="'+index+'"][value="'+value+'"]').prop('checked', true);
});
});
@jimmyko
Copy link

jimmyko commented Jun 3, 2016

$(document).data() is not a good way to store the radio value.

@amit-srivastava-007
Copy link

amit-srivastava-007 commented Sep 5, 2017

What is me.$el ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment