A good option is to try to put this functionality in the view model rather than relying on the DOM elements. For example, you can attach an id
to the observableArray rather than the DOM element. Like:
this.myItems = ko.observableArray();
this.myItems.id = "myId";
Then, you can just look at arg.targetParent.id
.
Alternatively, you can subscribe in your viewmodel like:
this.myItems.subscribe(function(newValue) {
this.createLink("myItems", newValue); //or whatever you need to do in your code
}, this);
The beforeMove
and afterMove
handlers to pass the event
and ui
objects on as the second and third arguments, so you could inspect them and find the parent of the element.
Knockout does not have a generic way to get a DOM element from an observable, as an observable may be bound to many elements. Hope this gives you some ideas though.