Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • David Conlisk 432 posts 1008 karma points
    Apr 26, 2013 @ 14:25
    David Conlisk
    0

    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

  • Dan Patching 31 posts 158 karma points c-trib
    Apr 26, 2013 @ 14:39
    Dan Patching
    1

    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.

  • Lee Kelleher 4024 posts 15833 karma points MVP 13x admin c-trib
    Apr 26, 2013 @ 14:42
    Lee Kelleher
    0

    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.

  • Lee Kelleher 4024 posts 15833 karma points MVP 13x admin c-trib
    Apr 26, 2013 @ 14:43
  • Lee Kelleher 4024 posts 15833 karma points MVP 13x admin c-trib
    Apr 26, 2013 @ 14:48
    Lee Kelleher
    1

    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...

    Cheers, Lee.

  • David Conlisk 432 posts 1008 karma points
    Apr 26, 2013 @ 14:53
    David Conlisk
    0

    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

  • Lee Kelleher 4024 posts 15833 karma points MVP 13x admin c-trib
    Apr 26, 2013 @ 14:55
    Lee Kelleher
    0

    Could ask Lennart (the developer) if he encountered this - and if there is a workaround?  He's also on twitter: @TheAmph

  • David Conlisk 432 posts 1008 karma points
    Apr 26, 2013 @ 15:53
    David Conlisk
    101

    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:

    [assembly: WebResource("TheseDays.Umbraco.DataTypes.OpeningHours.Scripts.jquery-1.5.1.min.js", "text/javascript")]

    and

    this.AddResourceToClientDependency("TheseDays.Umbraco.DataTypes.OpeningHours.Scripts.jquery-1.5.1.min.js", ClientDependencyType.Javascript);

    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! :)

    Cheers,

    David

     

     

  • Lennart Stoop 304 posts 842 karma points
    Apr 30, 2013 @ 00:22
    Lennart Stoop
    0

    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

  • David Conlisk 432 posts 1008 karma points
    Apr 30, 2013 @ 09:20
    David Conlisk
    0

    Hi Lennart,

    No worries. It was in a site I'd inherited, I'd never seen the package before - very useful!

    Thanks,

    David

Please Sign in or register to post replies

Write your reply to:

Draft