开发者

Change helper ID

开发者 https://www.devze.com 2023-02-19 19:57 出处:网络
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:

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

精彩评论

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

关注公众号