Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New to the CF scene
    Join Date
    Jan 2007
    Posts
    4
    Thanks
    2
    Thanked 0 Times in 0 Posts

    modify prototype.js

    Hi,

    I know there's a sticky posting regarding the issue I'm facing, but I do hope to get some help even though I'm pretty sure you've read about this hundreds of times.

    Well, I have a page that needs to use both prototype and jquery frameworks, and without changing the jquery files. So, to make a long story short, is there a way to modify the prototype.js file so that it doesn't clash with jquery? If so, will I also need to modify all the .js files on my site that use the prototype framework?

    Thanks.

  • #2
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,919
    Thanks
    6
    Thanked 1,040 Times in 1,013 Posts
    First let me still ask you: do you really need to use both frameworks? What exactly are you trying to do?

  • #3
    New to the CF scene
    Join Date
    Jan 2007
    Posts
    4
    Thanks
    2
    Thanked 0 Times in 0 Posts
    well, I've been using a really-really-really lovely and cool balloon toolip for years, and it uses prototype. The problem is that one of my clients now wants some specific jquery functions (to allow the user to select an area from a picture and save that area to a file)... so I would prefer to use both frameworks so that I don't have to switch to a new balloon tooltip.

    This will happen only on the page of the jquery image selection page, so I won't be running into any problems on my other pages... so I would prefer to go the hard way. Could I have your help?

  • #4
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,398
    Thanks
    12
    Thanked 570 Times in 563 Posts
    Generally it would be a good idea to run jQuery in noConflict mode. So it should be possible for you to run both jQuery and prototype libraries with (mostly) no change

    Example:
    Code:
    var jQ = jQuery.noConflict();
    (function($) {
       // move all of your jQuery code here. You will be able to use $ for all jQuery related methods here, but prototype won't work here
    })(jQ);
    
    // here you can use $ from prototype

  • #5
    Regular Coder
    Join Date
    Apr 2012
    Location
    St. Louis, MO
    Posts
    985
    Thanks
    7
    Thanked 101 Times in 101 Posts
    I've never used jQuery in noConflict mode, so can't speak to how well that works. But I've always understood that using ONE library is the best approach.

    jQuery does have a nice tooltip, by itself, and there is a jQuery plugin for balloon tooltips that is also very nice, and could probably do a balloon tooltip that is not too different from what you're currently using.

    But if you insist on using both libraries, then devnull69's suggestion should work.
    ^_^

    If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
    *
    The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".

  • #6
    Senior Coder
    Join Date
    Apr 2011
    Location
    London, England
    Posts
    2,120
    Thanks
    15
    Thanked 354 Times in 353 Posts
    I still suggest it is worthwhile having a look at jquery alternative tooltips such as this one. If not, devnull69's code looks cool
    "I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
    Validate your HTML and CSS

  • #7
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,919
    Thanks
    6
    Thanked 1,040 Times in 1,013 Posts
    Yes, I’d also pledge for a jQuery tooltip then. After all, styling is usually done with CSS so it should be no major issue to make it look exactly the same. jQuery’s “noConflict” mode should really only be the very last resort if you have no control over parts of the site or other scripts.

  • #8
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,642
    Thanks
    0
    Thanked 649 Times in 639 Posts
    You don't even need to define a jQ variable because $ is just an alias for the jQuery variable in jQuery even when you don't use noconflict.

    Code:
    jQuery.noConflict();
    (function($) {
       // move all of your jQuery code here. You will be able to use $ for all jQuery related methods here, but prototype won't work here
    })(jQuery);
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •