1 回答

TA贡献1798条经验 获得超3个赞
问题是 draggable 函数只适用于 DOM 元素,而不适用于动态创建的元素。
可以重新调用AJAX done中的draggable函数来解决问题。
function GetList() {
$.ajax({
url: "/List.asmx/List1",
type: "GET",
dataType: "json",
data: {
},
contentType: "application/Json; Charset= Utf-8",
success: function (data) {
var list = "";
$.each(data.d, function (index, item) {
list += '<div itemid=' + item.Nu + ' class="btn btn-default box">' + item.Name + '</div>';
});
$("#container1").html(list);
},
done: function (response) {
$('#container1 .box').draggable({
cursor: 'move',
helper: "clone"
});
},
error: function (response) {
alert(response);
}
});
}
添加回答
举报