tanquach (1) [Avatar] Offline

Can you provide a full example of using jQuery.noConflict() to avoid namespace conflicts from Chapter 2?

Where would I add this (snippet from Listing 2.4) in my third-party library?

var RatingWidget = RatingWidget || {};
RatingWidget.$ = jQuery.noConflict(true);

Let's say that I concatenate jQuery, fancybox and my own library (RatingWidget.js) into one file. In the RatingWidget.js library, how would I reference the $ variable?

benvinegar (68) [Avatar] Offline
Re: Using jQuery.noConflict()
Through RatingWidget.$.

But, you can safely alias this variable back to $ inside a private function scope afterwards. For example:

(function() {
var $ = RatingWidget.$;