0
我有一個簡單的應用程序,它使用Knockout JS綁定到視圖模型。它使用了一個foreach循環,當一個新項目添加到視圖模型中時觸發Knockout afterAdd事件。結果應該是一個Kendo可拖動的,可以放在目標上。出於某種原因,我無法在目標上觸發放置事件。Kendo UI droppable drop event not firing
<button data-bind="click: $root.add">Add</button>
放置目標
var ViewModel = function() {
this.operations = ko.observableArray([]);
this.add = function() {
this.operations.push("drag");
}.bind(this);
this.bind = function() {
$(".draggable").kendoDraggable({
hint: function (e) {
$("#console").append("<li>firing hint</li>");
return e.clone();
},
});
$(".droptarget").kendoDropTarget({
drop: function (e) {
$("#console").append("<li>firing drop</li>");
}
});
};
};
ko.applyBindings(new ViewModel());
它發生在我身上,可能是這個問題。我試圖在實例化它們之前實現一些代碼來銷燬事件,但它不起作用。我使用$(「selector」)。unbind(「。kendo-dnd」)。無論何時將新成員添加到操作中,都需要在DOM準備就緒後添加可拖動/放置事件。 – user135498 2014-09-23 16:50:56