开发者

draggable connect to sortable (change the id)

开发者 https://www.devze.com 2023-01-22 08:26 出处:网络
I have a ui draggable that connects to a sortable list with helper clone. 开发者_开发百科$(\".mydrag\").draggable({

I have a ui draggable that connects to a sortable list with helper clone.

开发者_开发百科
$(".mydrag").draggable({
                helper:'clone',
                handle: '.drag',
                connectToSortable:'.new',
                start: function(event, ui) { console.log(ui);
                    var id = ui.helper[0].id;

                    $(ui.helper).attr("id","new-"+id);

                }


            });

When start the drag I and a prefix of "new-" at the id expecting that when received by the sortable will sit as new-id. But its not working.

I also tried to change the context

$(ui.helper.context).attr("id","new-"+id);

but in this case change the id of the received element in the sortable BUT it also change the id of the original item

I also tried to change the id when sortable receives the new element but change the id of the original item (because when receiving there are 2 elements with the same id)

So I am really stuck. Any help appreciated

0

精彩评论

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