8

I kind of feel bad asking yet another Cannot Read Property 'length' of Undefined question, but no online (SE or otherwise) answers are in any way relating to my problem at hand.

I have tried my best to narrow down why this script error is occurring for my situation, but I am at a loss.

If I exclude this tag in the page, the error ceases to show up:

<script src="~/Plugins/jquery-ui-1.10.3.drag-drop.min.js" type="text/javascript"></script>

All that the jquery-ui-1.10.3.drag-drop.min.js file is is a jquery-custom file I renamed, that includes jquery draggable, droppable, and sortable.

I was sure that the error was caused by some script I wrote, but as I have just begun to test this out, I didn't have much script to 'comment out', and when I did so, it, to my befuddlement, didn't get rid of the error. The only way I have found so far to get rid of the error is to exclude the plug-in altogether, which I obviously wouldn't be able to use if I did.

The error in full as seen in Chrome's debugger:

Uncaught TypeError: Cannot read property 'length' of undefined      jquery-1.9.1.min.js:3
b.extend.each                                                       jquery-1.9.1.min.js:3
e.widget                                                            jquery-ui-1.10.3.drag-drop.min.js:6
(anonymous function)                                                jquery-ui-1.10.3.drag-drop.min.js:6
(anonymous function)                                                jquery-ui-1.10.3.drag-drop.min.js:6

The problem is (as it is with most errors like this) that I can't track down why this is causing an error, even if no code is written to even make use of this plug-in yet.

I am using jquery-1.9.1.min.js and the jquery-migrate-1.2.1.min.js files.

Truth is, I could ignore this error, as it doesn't really break anything, and the dragging, dropping, and sortable features all seem to work fine and as expected. I just think it is ugly to have script errors in your page, and as I have never tolerated them in the past, I didn't really want to start tolerating them now.

Am I barking up the wrong tree? Does the error not point to my drag-drop file? What can I do to help narrow this error down?

Please let me know if there is any more information I can supply that would help.

AS REQUESTED-<script> tags as they appear in the <head> Tag:

<script src="~/Resources/jquery-1.9.1.min.js" type="text/javascript"></script>
<script src="~/Resources/jquery-migrate-1.2.1.min.js" type="text/javascript"></script>
<script src="~/Plugins/jquery.maskedinput.min.js" type="text/javascript"></script>
<script src="~/Plugins/jquery-ui.min.js" type="text/javascript"></script>
<script src="~/Plugins/accounting.min.js" type="text/javascript"></script>
<script src="~/Plugins/jquery.autoellipsis-1.0.10.min.js" type="text/javascript"></script>
<script src="~/Plugins/jquery-ui-1.10.3.drag-drop.min.js" type="text/javascript"></script>
<script src="~/Scripts/PluginConfigurations.js" type="text/javascript"></script>
<script src="~/Scripts/main.js" type="text/javascript"></script>
<script src="~/Scripts/EditPages.js" type="text/javascript"></script>
VoidKing
  • 6,282
  • 9
  • 49
  • 81
  • 1
    Maybe it's an error within the plugin? Can you get rid of everything on your page EXCEPT the plugin, and see if it still occurs? – andi Sep 09 '13 at 14:08
  • can you show all your rendered script tags in the order they are run – Pete Sep 09 '13 at 14:23
  • @Pete There you go, Sir – VoidKing Sep 09 '13 at 15:21
  • @andi Do you mean everything except the plug-in and the reference to jquery 1.9.1? Or really just everything but the plug-in itself? – VoidKing Sep 09 '13 at 15:23
  • 3
    does the jquery-ui.min.js not cover the plugins in the jquery-ui-1.10.3.drag-drop.min.js? – Pete Sep 09 '13 at 15:28
  • yeah, jQuery should stay in, of course. – andi Sep 09 '13 at 15:32
  • @Pete Hmmm... It appears as though it does. I just got rid of the script tag that referenced that file and found that all of my dragging, dropping, and sortable features still work. I guess (whenever it was that I got that file) I didn't realize that it contained all of the jquery-ui plugins together. Do I understand this right: Normally, the `jquery-ui-min.js` is a minified version of a .js file that contains all of the jquery ui plug-ins in one package? – VoidKing Sep 09 '13 at 15:49
  • @Pete Also, now that you mention that, I never have had any luck getting any "custom-ui" packages to work correctly. I'll bet it wouldn't have even worked, and that the "jquery-ui-min.js" file was probably handling any successful functionality that was occuring with these features. I'm not sure how I overlooked that one, and I'm even less sure about how you would make this into an answer, but should you, I will upvote and accept. It certainly seems to have solved my issue. Thank you! – VoidKing Sep 09 '13 at 15:52
  • 4
    I think that it is just a minified version of all plugins (unless you have selected to download specific parts of the ui), glad I could help - don't know how to make it into an answer either! – Pete Sep 09 '13 at 15:56
  • @Pete Well, if you manage to work something up, there's free points in it for you :) (Well, I guess it's not free, considering your work in helping me, but that is, I guess, why I am eager to reward you). Thanks again :) – VoidKing Sep 09 '13 at 16:21

2 Answers2

18

As @Pete has helped you identify, it is indeed caused by duplicating your jQuery UI core scripts. Load just them once, and your 'length of Undefined' issue will go away.

Denseflux
  • 316
  • 2
  • 6
0

As @Pete has helped you identify, it is indeed caused by duplicating your jQuery UI core scripts. Load just them once, and your 'length of Undefined' issue will go away.

Including below file twice,will cause this issue.

jquery.ui.core.min.js

Make sure you have included only once.