Change helper ID
I made a draggable, sortable div and what I want is to change the clone ID after dragging it, but my script changes the IDs of both the original and the clone. My code is as follows:
var i = 0;
$('#colum').draggable({
开发者_开发问答 helper:'clone',
connectToSortable:'#sort',
start: function(event,ui) {
i++;
$(this).attr("id","colum"+i);
}
});
$('#sort').sortable({
connectWith: "#sort",
containment: "#sort"
)};
You can get at the sortable helper by accessing the ui
variable passed into the start
event - ui.helper
.
$('#sort').sortable({
helper: 'clone',
start: function(event, ui) {
ui.helper.attr('id', 'mycustomid'); //ui.helper is a jquery object pointing to the helper
},
connectWith: "#sort",
containment: "#sort"
)};
精彩评论