BorisMoore/jsrender — Issue #69: Overiding jQuery Variable - noConflict() compatibility
Author: jmealo
Created: 2012-01-27 23:14:23+00:00
State: open

In the template generation code 'jQuery' is used in a string. The problem here is that this doesn't evaluate as a reference to the jQuery variable inside of jsrender, it ends up referring to window.jQuery which may be a different version.

This makes the assumption we want to use the default jQuery library thus making the library incompatible with multiple jQuery versions running concurrently.

I was able to use the code as-is with deferred loading, however, when that became an issue with another library I found that the only way I could use jsrender was to replace 'jQuery' with '$jq' which references the version of the library I wanted to use.

Note: I defined jQuery = $jq and $ = $jq at the top of the jsrender file and still got errors. That's when I realized this was a scope problem. Changing the 'jQuery' inside of the string to '$jq' fixed it.