Making Smart Menu's work with Prototype javascript library

Home Forums Older releases 0.9.x Making Smart Menu's work with Prototype javascript library

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #1333
    max
    Participant

    Side note, I have some old code that uses the Prototype library.
    Prototype uses the “$” to declare Javascript objects which conflicts with Jquery and prevented my smartmenu from running

    (see http://learn.jquery.com/using-jquery-core/avoid-conflicts-other-libraries/)

    I did the following to fix this problem.

    First I load prototype and then I load jquery




    Now I took "jquery.smartmenus.min.js" and with editor I replaced each occurrence of
    "$" with "$j". Just like above.

    And now both my old prototype stuff works in my smartmenu stuff works

    #1614
    admin
    Keymaster

    Hi,

    Actually, you don’t need to edit jquery.smartmenus.min.js at all, you can use the stock version. It doesn’t use $ but jQuery and when you add this:

    var $j = jQuery.noConflict();

    jQuery will free the $ variable but will keep jQuery so you could still use any plugins (that are properly coded to not rely on $) without any modifications. But yes, for the initialization lines, you would need to replace $ with $j or jQuery like you’ve done.

    Cheers!

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

Register

You will be emailed a link to set your password.

Login

Lost password?