Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-10-2012, 07:51 AM   PM User | #1
billgates2000
New to the CF scene

 
Join Date: Jan 2007
Posts: 4
Thanks: 2
Thanked 0 Times in 0 Posts
billgates2000 is an unknown quantity at this point
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.
billgates2000 is offline   Reply With Quote
Old 12-10-2012, 12:12 PM   PM User | #2
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,592
Thanks: 5
Thanked 865 Times in 842 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
First let me still ask you: do you really need to use both frameworks? What exactly are you trying to do?
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Old 12-10-2012, 01:23 PM   PM User | #3
billgates2000
New to the CF scene

 
Join Date: Jan 2007
Posts: 4
Thanks: 2
Thanked 0 Times in 0 Posts
billgates2000 is an unknown quantity at this point
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?
billgates2000 is offline   Reply With Quote
Old 12-10-2012, 03:43 PM   PM User | #4
devnull69
Senior Coder

 
Join Date: Dec 2010
Posts: 2,245
Thanks: 10
Thanked 531 Times in 525 Posts
devnull69 will become famous soon enough
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
devnull69 is offline   Reply With Quote
Old 12-10-2012, 03:49 PM   PM User | #5
WolfShade
Regular Coder

 
Join Date: Apr 2012
Location: St. Louis, MO, USA
Posts: 945
Thanks: 7
Thanked 97 Times in 97 Posts
WolfShade is an unknown quantity at this point
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".
WolfShade is offline   Reply With Quote
Old 12-10-2012, 04:12 PM   PM User | #6
AndrewGSW
Senior Coder

 
Join Date: Apr 2011
Location: London, England
Posts: 2,120
Thanks: 15
Thanked 354 Times in 353 Posts
AndrewGSW will become famous soon enough
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
AndrewGSW is offline   Reply With Quote
Old 12-10-2012, 04:32 PM   PM User | #7
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,592
Thanks: 5
Thanked 865 Times in 842 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
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.
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Old 12-10-2012, 06:03 PM   PM User | #8
felgall
Master Coder

 
felgall's Avatar
 
Join Date: Sep 2005
Location: Sydney, Australia
Posts: 5,449
Thanks: 0
Thanked 496 Times in 488 Posts
felgall is a jewel in the roughfelgall is a jewel in the roughfelgall is a jewel in the rough
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/
felgall is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:09 AM.


Advertisement
Log in to turn off these ads.