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); }
Thierry Nivelet (FoxInCloud)
Never explain, never complain (Queen Elizabeth II) - ban but and not