Quantcast
Channel: West Wind Message Board Messages
Viewing all articles
Browse latest Browse all 10393

Re: take a look at this fic page problem

$
0
0
Re: take a look at this fic page problem
FoxInCloud
Re: take a look at this fic page problem
Jul. 23, 2013
01:08 am
3U702G4N8Show this entire thread in new window
Gratar Image based on email address
From:FoxInCloud support
To:Rick Strahl
Using a self executing function such as Rick recommends is very convenient to make everything clear.

FoxInCloud provides the code below that allows mixing jQuery's $() and Prototype's $() without the need for jQuery.noConflict().

This allows devs to just copy and paste jQuery code found on the Internet (mostly written using $()), without the need for a self executing function [(function($){...})(jQuery)], a concept that is difficult to understand for a VFP developer.

// Build a jQuery and Prototype compatible $()if (true&& $ // $() exists under firebug without jQuery&& window.jQuery&& $ === jQuery&& jQuery.noConflict() // restores Prototype.js!$() ) { $_ = $; // saves Prototype.js!$() $ = function(s){// if (s === document) return jQuery(s);if (Object.isElement(s)) return $_(s); // Prototypeif (typeof s !== 'string') return s;if (s.replace(/[0-9a-z\-_:\.]/gi, '').length > 0) return jQuery(s); // contient d'autres caractères que ceux admis dans un ID HTML : forcément un sélecteur CSS /* ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (" :"), and periods (".") */ if (s.replace(/[a-z]/gi, '').length > 0) return $_(s); // contient des caractères non alphabétiques - forcément un id if (document.getElementsByTagName(s).length > 0) return jQuery(s); // tagreturn $_(s); // id avec seulement des caractères alphabétiques }; Object.extend($, jQuery); }

You should wrap your jQuery code into a jquery safe block:

(function ($,undefined) {// ... your jQuery related code here })(jQuery)

This ensures that everything jQuery related and soped to $ uses jQuery overriding Prototype's $ function. As long as you have no plugins that aren't noconflict aware (ie. use this same approach which is pretty standard) this should work to keep Prototype and jQuery separate. Just make sure you use non-obtrusive JavaScript for all your JS code and you'll have no problems.


You can also use jQuery.noConflict:

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

but frankly that's more limited although that might be a good way to make clear what's jQuery and Prototype.

+++ Rick ---

I think the problem is that with jQuery added it broke some prototype stuff. Without jQuery this works:

* note, not relevant at this point, but update function replaces html. javascript is* handled differentlyif wlAjax() AJAX.cScriptJSAdd(textmerge([$('mainmenu').update("");])) ENDIF

With jQuery running the code does not work in IE.

.. even though probably not an Fic issue, check thread 3U50Z3A6S .





Thierry Nivelet (FoxInCloud)
Never explain, never complain (Queen Elizabeth II) - ban but and not


Viewing all articles
Browse latest Browse all 10393

Trending Articles