I restored my original code that had the response.js but it still doesn't
work. The ajax call is not getting made. What could be causing this?
My restored "user" controller is this:
def register():
...
register_form = SQLFORM.factory( db.auth_user, ... )
...
if register_form.process(formname='register-form',
onvalidation=validate_registration).accepted:
# create user
user_id = db.auth_user.insert(
first_name='',
last_name='',
email=register_form.vars.email,
... other stuff ...
password=register_form.vars.password,
)
... do a lot of group and permission stuff ...
# auto log them in
from gluon.storage import Storage, Settings, Messages
session.auth = Storage(user=db.auth_user[user_id],
last_visit=request.now,
expiration=auth.settings.expiration)
response.flash = 'Welcome message'
# THE PROBLEM IS THIS AJAX CALL IS NOT GETTING EXECUTED
response.js = 'ajax("%s", [], ":eval");' % URL(
c='user', f='cb_after_login')
elif register_form.errors:
response.flash = T('Please correct error in registration form')
return dict(register_form=register_form)
'
My view has this:
{{= LOAD('user', 'register.load', ajax=True, ...)}}
and register.load is a custom form, but basically {{=register_form}}
The form displays properly and submits properly except for the ajax call.
The user gets created properly, it's just there's no follow up ajax call
that's needed to clean up the screen.