My bootstrap modal won't close when the user clicks the submit button. Console says, "Uncaught TypeError: undefined is not a function"
Here's what I'm doing.
# view does a load of a skeleton
{{= LOAD('contact', 'dialog.load', ajax=True)}}
# contact controller looks like this
def dialog():
return dict(html=DIV(
DIV(
DIV(
_class='modal-content',
),
_class='modal-dialog',
),
_class='modal autoModal fade',
_id='contact-dialog',
_role='dialog',
aria=dict(labelledby='contact-title', hidden='true'),
)
)
# document ready initializes modal
$(document).ready(function() {
$("#contact-dialog").modal({
show: false,
backdrop: false,
keyboard: true
});
});
# elsewhere in view, link is created that launches modal
A(current.T('Contact'), _href='#',
_title=current.T('For a good time, call ...'),
_onclick="""web2py_component("%s","contact-dialog .modal-content");
$("#contact-dialog").modal("show");""" % URL('contact', 'form.load'),
),
Custom form is loaded AOK. All form functionality works hunky-dory (which means AOK for you non-native-English speakers). Errors caught perfectly by web2py. And then, for the coupé de gras:
if contact_form.process(formname='contact_form').accepted:
send_email(contact_form)
response.flash = SPAN(T('Message sent'), _class='success')
response.js = '$("#contact-dialog").modal("hide");' # <<< THIS IS WHERE THE TROUBLE IS!!
response.js gets executed. That's where I get the "Uncaught TypeError: undefined is not a function" message. I interpret this to mean that response.js is being treated like a function but there's no function.
Out of desperation, I went so far as to wrap a function around response.js like this:
response.js = '(function() {$("#contact-dialog").modal("hide");})();'
but that was utterly futile. OK web2py community, what gives? I used to do this all the time with jquery ui and had no trouble. But with bootstrap, it's a problem.