ah shoot, submit can also be triggered pressing "enter"...
guess we're stuck with this then...... opinions ? (if everybody agrees I'll
send a PR)
trap_form: function (action, target) {
/* traps any LOADed form */
$('#' + target + ' form').each(function (i) {
var form = $(this);
form.attr('data-w2p_target', target);
if(!form.hasClass('no_trap')) {
form.submit(function (e) {
console.log(form.serialize())
web2py.disableElement(form.find(web2py.formInputClickSelector));
web2py.hide_flash();
web2py.ajax_page('post', action, form.serialize(), target, form
);
e.preventDefault();
});
/* simulating behaviour of non-ajax forms, where the click on a
submit
button also submits its name and value */
form.on('click', web2py.formInputClickSelector, function (e) {
e.preventDefault();
var input_name = $(this).attr('name');
if (input_name != undefined) {
$('<input type="hidden" />').attr('name', input_name)
.attr('value', $(this).val()).appendTo(form)
}
form.trigger('submit');
})
}
});
},
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.