One option would be to add a little droppable
binding that plays nice with the sortable
and draggable
bindings. There are a few ways that you could do it, but here is one way where you pass a handler to droppable and it calls the handler passing the new item as the first argument.
ko.bindingHandlers.droppable = {
init: function(element, valueAccessor) {
var dropHandler = valueAccessor() || {};
$(element).droppable({
drop: function(event, ui) {
var item = ko.utils.domData.get(ui.draggable[0], "ko_dragItem");
if (item) {
item = item.clone ? item.clone() : item;
dropHandler.call(this, item, event, ui);
}
}
});
}
};
Then, you would bind it like:
<div id="main" data-bind="droppable: addTask">
With addTask
pushing to your observbaleArray.
Sample here: http://jsfiddle.net/rniemeyer/3JBnh/