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

don't use eval in this way #72

Open db48x opened 10 years ago

db48x commented 10 years ago

It calls eval on a string containing a variable name; when the minification happens and the variable is renamed, the result is a runtime error.

saz commented 10 years ago

Your change results in the following error message:

Uncaught TypeError: Property '$("#id_date").val' of object [object global] is not a function 

The json received from the server:

[{"fun": "$(\"#id_date\").val", "cmd": "data", "val": "2014-04-08"}]

I've reverted this change in my fork.

db48x commented 10 years ago

I hear ya. Perhaps there should be something along the lines of [{"cmd": "method", "elem": "#id_date", fun: "val", "val": "2014-04-08"}], but that's not for me to say. In any case, you could just use [{"cmd": "js", "val": "$(\"#id_date\").val(\"2014-04-08\")"}], although I agree it's not as nice.