rniemeyer / knockout-sortable

A Knockout.js binding to connect observableArrays with jQuery UI sortable functionality
MIT License
547 stars 128 forks source link

Item is getting destroyed when dropped over #154

Open xaviergxf opened 8 years ago

xaviergxf commented 8 years ago

Hi,

I'm having a little problem with knockout-sortable: when an item is dragged and dropped into another(try dragging the last item into the first one) the item dragged gets destroyed.

Here's my source code:

<!-- ko with: $data.ParentMetadataField ? $data: $.extend($data, {ParentFieldName:$module.GetParentFieldName($data)}) -->
<div class="navbar navbar-default" role="navigation">
    <div class="collapse navbar-collapse navbar-ex1-collapse">
        <ul class="nav navbar-nav" data-bind="sortable:{data:$module.GetItems(Model, ParentFieldName), template: '9612DDCC02C84BCCBAE864BC93AF9D86'}"/>
    </div>
</div>
<!-- /ko -->
<script id="9612DDCC02C84BCCBAE864BC93AF9D86" type="text/html">
<li data-bind="css:{'menu-item':true, dropdown:true, 'dropdown-submenu':!$parent.Model}">
    <a href="#" class="dropdown-toggle" data-toggle="dropdown">
        <!-- ko text: $root.ToString(Title) --><!--/ko-->
        <!-- ko if: $parent.Model -->
            <b class="caret"></b>
        <!--/ko-->
    </a>
    <ul class="dropdown-menu" data-bind="sortable:{data:$module.GetItems($component.Model, $component.ParentFieldName, $data.ID()), template: '9612DDCC02C84BCCBAE864BC93AF9D86'}"/>
</li>
</script>

I'm using jQuery v2.1.4, jQuery UI Sortable 1.11.4 and ko v3.4.0

Can you help me?

Thanks!

xaviergxf commented 8 years ago

It seems the problem has something to do with the first ul class navbar-nav. If we remove this class the example works. Perhaps something to do with its position?