views:

40

answers:

1

Ok, so I am using the facebox plugin. One of the examples given is to trigger the popup, trigger a spinner, do an ajax call, when the call returns replace the spinner with the results. Code is here

jQuery.facebox(function($) { 
 $.get('blah.html', function(data) { $.facebox(data) })
})

A few questions.

  1. I thought that the jQuery and $ variables were the same thing, and you use jQuery only when there are naming conflicts with other libraries. In this example, the author calls jQuery.facebox and passes in a function with $ as a param. Am I misunderstand the difference between the two?
  2. in the .get callback, we are calling $.facebox is $ in that context the jquery global, or is it the variable passed in to the outer function?

Thanks for the clarification :-)

+1  A: 

I believe the author is sanitizing (freeing from any conflicts) $ by passing it to itself--the first jQuery is to make sure it's jQuery doing it, and the jQuery object $ makes it okay to use. Just a precaution.

D_N
That makes sense. I think I need to read up more on JQuery best practices....
Matt Briggs