TypeError: jQuery(...).MultiNodeTreePicker is not a function
Hi all,
This is a strange one. My MNTP datatype works on one page of my site (the homepage) but not another (store page). In the store page it renders fine, but doesn't function (i.e. you can't select any nodes) - presumably because of the javascript error mentioned in the title.
I've tried updating the ClientDependency number. There are no other javascript errors. I've re-installed the latest version of uComponents (v5.4.1). This is an Umbraco site that I've upgraded from v4.9 to the latest (v.4.11.7), with no other issues
Any suggestions on what to try would be most appreciated!
Which MNTP are you using? (If it's prefixed with "uComponents-Legacy" or not)
From looking at the HTML you posted, my guess is that another data-type has some JS which is either causing an error (e.g. no subsequent JS executes) or conflicts with it (somehow?!) My guess is that it's "Opening Hours".
Re-looking at your HTML source. Found this line in OpeningHours:
var jq151 = jQuery.noConflict(true);
I don't know enough about what OpeningHours does, but given the variable is called "jq151" I'm guessing that it tries to pull in an older version of jQuery, which would most likely make other things go boom. Hmmmm...
OK I got this sorted, but I'm not sure this is a general-purpose solution. Lee, maybe you can shed some light - can I assume in my package that jQuery will be defined?
What I've done is this:
- downloaded the source code to OpeningHours
- removed the following lines from OpeningHoursEditor.ascx.cs:
This stops the package from registering its own version of jQuery. Then, in OpeningHoursEditor.ascx, I changed the code so that it assumes jQuery is already defined and just uses the jQuery variable without doing any other checks - this is the bit that I'm not sure it's safe to do in general! But it works just now for me in my current project ("it works on my machine" (tm)).
So, instead of calling
var jq151 = jQuery.noConflict(true);
and then using jq151 instead of jQuery (which is, it seems, the "right" way to use noConflict: http://api.jquery.com/jQuery.noConflict/), I removed the call to noConflict and replaced all references to jq151 back to regular jQuery in that user control. I compiled the code, dropped the dll and .ascx file into my Umbraco installation, and it works. Phew!
Hope that helps someone. It would be good to know if this is a safe solution too! :)
I just read your message on twitter, I'm sorry I didn't get back to you any sooner.
To shed some light on the Jquery magic.. At the time the package was released the Umbraco back-office was still referencing an old version of Jquery which did not contain the autocomplete plugin. If I remember correctly I also wasn't able to embed the plugin seperately because it had dependencies to a different version of Jquery.
Since removing the Jquery 1.5.1 dependency works for you, I'm guessing your Umbraco installation references a more recent version of Jquery so it's no longer an issue and you should be fine. I will look into it myself as well (might also have to remove the Jquery UI dependency) and create a new download for recent installs.
TypeError: jQuery(...).MultiNodeTreePicker is not a function
Hi all,
This is a strange one. My MNTP datatype works on one page of my site (the homepage) but not another (store page). In the store page it renders fine, but doesn't function (i.e. you can't select any nodes) - presumably because of the javascript error mentioned in the title.
I've been trying to debug this for ages, comparing the source of the two frames, and I can't work out what's going wrong. Here is a link to the source markup of the edit content frame that is not working (i.e. /umbraco/editContent.aspx?id=x). (For reference, this is the homepage, and this one works).
I've tried updating the ClientDependency number. There are no other javascript errors. I've re-installed the latest version of uComponents (v5.4.1). This is an Umbraco site that I've upgraded from v4.9 to the latest (v.4.11.7), with no other issues
Any suggestions on what to try would be most appreciated!
Cheers,
David
I had a similar issue to this when using MNTP with an old version of OpenCalais tags.
The issue was a javascript conflict between the 2 data types.
OpenCalais was overiding some events that MNTP needed.
Not sure what else you have on this node, but I would check out the other data types there.
A tweak to the OpenCalais js fixed the issue for me. (and was still fixed when I upgraded to latest version of it).
Hope this helps.
Hi David,
Which MNTP are you using? (If it's prefixed with "uComponents-Legacy" or not)
From looking at the HTML you posted, my guess is that another data-type has some JS which is either causing an error (e.g. no subsequent JS executes) or conflicts with it (somehow?!) My guess is that it's "Opening Hours".
Cheers, Lee.
Yup, I think it's Opening Hours... just found this: http://our.umbraco.org/projects/backoffice-extensions/openinghours/bugs/33321-doesnt-work-in-combination-with-Multi-Node-Treepicker
Re-looking at your HTML source. Found this line in OpeningHours:
I don't know enough about what OpeningHours does, but given the variable is called "jq151" I'm guessing that it tries to pull in an older version of jQuery, which would most likely make other things go boom. Hmmmm...
Cheers, Lee.
Hi Dan, Lee,
Thanks both for taking time to have a look :)
Lee, you're right, that's the issue - removing the Opening Hours attribute on the Store doctype fixes the page. Now we're getting somewhere!
Now to work out how to get around it...
David
Could ask Lennart (the developer) if he encountered this - and if there is a workaround? He's also on twitter: @TheAmph
OK I got this sorted, but I'm not sure this is a general-purpose solution. Lee, maybe you can shed some light - can I assume in my package that jQuery will be defined?
What I've done is this:
- downloaded the source code to OpeningHours
- removed the following lines from OpeningHoursEditor.ascx.cs:
and
This stops the package from registering its own version of jQuery. Then, in OpeningHoursEditor.ascx, I changed the code so that it assumes jQuery is already defined and just uses the jQuery variable without doing any other checks - this is the bit that I'm not sure it's safe to do in general! But it works just now for me in my current project ("it works on my machine" (tm)).
So, instead of calling
and then using jq151 instead of jQuery (which is, it seems, the "right" way to use noConflict: http://api.jquery.com/jQuery.noConflict/), I removed the call to noConflict and replaced all references to jq151 back to regular jQuery in that user control. I compiled the code, dropped the dll and .ascx file into my Umbraco installation, and it works. Phew!
Hope that helps someone. It would be good to know if this is a safe solution too! :)
Cheers,
David
Hi David,
I just read your message on twitter, I'm sorry I didn't get back to you any sooner.
To shed some light on the Jquery magic.. At the time the package was released the Umbraco back-office was still referencing an old version of Jquery which did not contain the autocomplete plugin. If I remember correctly I also wasn't able to embed the plugin seperately because it had dependencies to a different version of Jquery.
Since removing the Jquery 1.5.1 dependency works for you, I'm guessing your Umbraco installation references a more recent version of Jquery so it's no longer an issue and you should be fine. I will look into it myself as well (might also have to remove the Jquery UI dependency) and create a new download for recent installs.
Sorry for the inconvenience!
Grtz
L
Hi Lennart,
No worries. It was in a site I'd inherited, I'd never seen the package before - very useful!
Thanks,
David
is working on a reply...