This is a migrated thread and some comments may be shown as answers.
Client Script Error When Enabling Drag And Drop
8 Answers 58 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Kevin Watkins
Top achievements
Rank 1
Kevin Watkins asked on 11 Apr 2010, 03:56 PM
Hi,

I've just added .DragAndDrop(true) to my tree to enable drag and drop and I'm getting script errors in jquery-1.4.2.js:

Line: 552
Error: 'length' is null or not an object

Tracing back into the Telerik script this is happening in the $t.treeview initialisation on the line:

$t.draganddrop(this.element.id, $.extend({  
    draggables: $('div:not(.t-state-disabled) .t-in', element)  
}, $t.draganddrop.applyContext($t.draganddrop.treeview, this))); 

$t.draganddrop.treeview is undefined, which breaks the $.each call in applyContext, giving the error in jquery-1.4.2.js.

Any ideas what might be causing it? I did notice that telerik.draganddrop.js is being registered after telerik.treeview.js in my HTML (it's the other way around in your demos) but presumably that wouldn't break things? I am using literal HTML for my nodes (as discussed in another forum post) and have four trees on the page; don't know if either of those would matter? (I can't see why)

Thanks,

Kev

8 Answers, 1 is accepted

Sort by
0
Accepted
Alex Gyoshev
Telerik team
answered on 12 Apr 2010, 12:20 PM
Hello Kevin,

The problem is caused exactly because of the order of the scripts. If you register the draganddrop.js first, the problem should perish. We are currently working on removing this restriction.

Sincerely yours,
Alex Gyoshev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Kevin Watkins
Top achievements
Rank 1
answered on 12 Apr 2010, 12:27 PM
Hi,

Can you add some text to that effect in the demos and the docs until you fix things so other people don't waste time with this issue? Currently in the demos it states "To allow reordering of the TreeView nodes, all you need to do is to call DragAndDrop(true)." which isn't true if I have to register the script manually beforehand... Similarly it's not mentioned in the docs.

Why doesn't the treeview component register the drag and drop script before the treeview script by the way? Is that what you mean by 'this restriction'?

Cheers,

Kev
0
Alex Gyoshev
Telerik team
answered on 12 Apr 2010, 02:23 PM
Hello Kevin,

As you can see in the drag&drop online demo, the script is automatically registered by the component in the required order. If you are registering the scripts manually, however, you have to watch out for the order of scripts, as outlined in the required JavaScript files help topic in the online documentation.

Best wishes,
Alex Gyoshev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Kevin Watkins
Top achievements
Rank 1
answered on 12 Apr 2010, 02:27 PM
Hi,

I'm not registering the scripts manually, I'm leaving it up to the treeview component, which is rendering them in the incorrect order.

Thanks,

Kev
0
Alex Gyoshev
Telerik team
answered on 12 Apr 2010, 02:33 PM
Hello Kevin,

Can you please provide some code so that we can reproduce it locally? Master page + View page + Partials (if any) should do, if a sample project is not easy to send.

Regards,
Alex Gyoshev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Kevin Watkins
Top achievements
Rank 1
answered on 12 Apr 2010, 03:26 PM
Hi,

I've worked out why I was getting the problems. It's because I have two trees in the page, the first doesn't have drag and drop, the second does. Therefore the first tree is registering the treeview script, then the second tree comes along and registers draganddrop and then treeview again. Overall result is that treeview gets registered before draganddrop.

I'll register the draganddrop script manually for this page.

Cheers,

Kev
0
zhitong zhao
Top achievements
Rank 1
answered on 29 Jun 2010, 07:48 PM
I am having this same exact problem.  Even if I register it manually (all in correct order), I still get the error.  We also have multiple trees on the page, one with and one without drag and drop.  it is important to note that the tree WITH the drag and drop is not loaded until AFTER the page is loaded (AJAX).  I have tried every combination that makes sense but nothing alleviates the issue.

Current registration code:

  <% Html.Telerik().ScriptRegistrar().DefaultGroup(group => group    
       .Add("jquery-1.4.2.min.js")             
       .Add("telerik.common.min.js")
       .Add("telerik.draganddrop.min.js")
       .Add("telerik.treeview.min.js")
       .Add("telerik.panelbar.min.js")
       .Add("telerik.menu.min.js")       
       .Add("telerik.tabstrip.min.js"));
    %>
    <%= Html.Telerik().ScriptRegistrar() %>
0
Atanas Korchev
Telerik team
answered on 30 Jun 2010, 06:42 AM
Hi zhitong zhao,

Unfortunately the provided information does not indicate what the problem may be. I suggest you open a support ticket and send us a sample project which illustrates the JavaScript error.

Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
TreeView
Asked by
Kevin Watkins
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
Kevin Watkins
Top achievements
Rank 1
zhitong zhao
Top achievements
Rank 1
Atanas Korchev
Telerik team
Share this question
or