jorgebastida / django-dajax

Easy to use library to create asynchronous presentation logic with django and dajaxice
http://dajaxproject.com/
BSD 3-Clause "New" or "Revised" License
346 stars 99 forks source link

Dajax global not set properly (jquery.dajax.core.js breaks with django-pipeline) #52

Open ngkabra opened 11 years ago

ngkabra commented 11 years ago

Django-pipeline (which is a css/js compressor) collects together all js files into a single js file, and then wraps it into an anonymous function like this:

(function(){ ... })();

This results in onclick scripts on all pages breaking because they cannot find Dajax. (Dajax is currently defined in jquery.dajax.core.js as a "var Dajax", so obviously it is not visible outside the anonymous function. Link.

Suggested fix: At the end of the file, expose the Dajax variable:

window.Dajax = Dajax

(as is done by jQuery).

Temporary workaround for others facing the same problem:

Set PIPELINE_DISABLE_WRAPPER = True

to disable wrapping all the code in an anonymous function. This works but is not an ideal solution.