django-dajax icon indicating copy to clipboard operation
django-dajax copied to clipboard

don't use eval in this way

Open db48x opened this issue 11 years ago • 2 comments

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.

db48x avatar Jan 17 '14 21:01 db48x

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.

saz avatar Feb 06 '14 12:02 saz

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.

db48x avatar Feb 13 '14 00:02 db48x