Question

I'm trying to detect when I have dropped an item in a treeview after dragging it. When I do, it just hangs indefinitely searching for the javascript function. Sometimes it finds it after 10 seconds and sometimes it doesn't. I've verified with Firebug that the function is always loading (and is only loading once).

My Kendo UI version is: 2012.2.913

Thanks in advance for any help or advice.

@(Html.Kendo().TreeView()
.Name("CompanyHierarchy")
.Events(events => events
    .DragEnd("HierarchyDragEnd")
)
.BindTo(Model.Hierarchy as System.Collections.IEnumerable, mappings =>
{
    mappings.For<Models.EnterpriseChildModel>(binding => binding
        .Children(c => c.Children)
        .ItemDataBound((item, c) =>
        {
            item.Text = c.Name;
        })
    );
})
.DragAndDrop(true))

<script type="text/javascript">
function HierarchyDragEnd(e) {
    alert("here");
}</script>

I don't know if it will help but here's a picture of it when it's 'frozen' enter image description here

Was it helpful?

Solution

It seems that there is a bug with Firefox (in Chrome your example works fine) for the dragend event. A workaround is to delay the result in order to let the dragend event being registered correctly like this :

function HierarchyDragEnd(e) {
    setTimeout(function() {
        alert('here');
    }, 100);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top