:eval not working

55 views
Skip to first unread message

Ruud Schroen

unread,
Apr 24, 2014, 12:20:31 PM4/24/14
to web...@googlegroups.com
Al of a sudden my callbacks aren't working. Whenever i specify :eval as the target, i get this error:

Uncaught Error: Syntax error, unrecognized expression: #:eval

which comes from jquery.js

This is my callback trigger, returned from a function:

return A(T('Send friend request'), callback=URL('default', 'friendship', args=['request', user.id]), _class='button white friendship', _id='friendship_button', target=':eval')

I am using the web2py.js and jquery.js from the welcome app.

What am i doing wrong?

Derek

unread,
Apr 24, 2014, 12:46:09 PM4/24/14
to web...@googlegroups.com
Are you not returning javascript?

Ruud Schroen

unread,
Apr 24, 2014, 12:47:44 PM4/24/14
to web...@googlegroups.com
new_button = SPAN(XML(T("✔ Friend request sent")), _class='button white friendship')
return "jQuery('#friendship_button').replaceWith('%s');" % new_button


Derek

unread,
Apr 24, 2014, 12:49:44 PM4/24/14
to web...@googlegroups.com
ah I caught it. you are doing this...


specifying a target for the 'a' tag. Unless it's _blank, _self, _parent, _top, or the name of a frame, that won't work.

I assumed you meant to do something like this:
ajax('echo', ['name'], ':eval')

Ruud Schroen

unread,
Apr 24, 2014, 1:30:01 PM4/24/14
to
Thanks Derek! Although i went for another approach:

I removed target=':eval' from the A helper, and instead of using a return, i used response.js

So now it's like this

new_button = SPAN(XML(T("✔ Friend request sent")), _class='button white friendship')
response.js = "jQuery('#friendship_button').replaceWith('%s');" % new_button

response.js seems to be some sort of special header, so it executes the jquery inside.


Reply all
Reply to author
Forward
0 new messages