【发布时间】:2023-04-10 15:11:02
【问题描述】:
我想做的是结合两个项目:
- One is an example of draggable and sortable list-items
- The other is jEditable, which I'm using to make the list-items editable
现在我可以毫无问题地将编辑类附加到第一个链接中的现有列表项。当我去创建一个新的可拖动项目(克隆)并将其移动到可排序列表时,我希望它采用旧项目的 css 类。我尝试将代码添加到可拖动的停止事件和可排序的接收事件中,但没有成功。改变的是原版的风格,而不是克隆版的。
receive: function(event, ui) {
alert("dropped item ID: " + ui.item.attr('id'));
$("#draggable").attr('class', 'edit');
}
stop: function() {
if ( !$( "#draggable" ).hasClass( "ui-state-hover" ) ) {
$( "#draggable" ).removeClass( "ui-state-highlight" );
$( "#draggable" ).addClass( "ui-state-default" );
$( "#draggable" ).addClass( "edit" );
}
}
我怎样才能做到这一点?
【问题讨论】:
标签: javascript jquery draggable jquery-ui-sortable jeditable