开发者

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"
)};
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜