fixed web2py.js for trapped non-self-submitting forms, thanks Vinicius

This commit is contained in:
mdipierro committed 2013-11-06 10:30:41 -06:00
1 parent 8e4f92ac64
commit 643e945540
4 files changed
+43 -10

No files matched your search

+1 -1
View File
@@ -1 +1 @@
Version 2.7.4-stable+timestamp.2013.11.03.22.45.08 Version 2.7.4-stable+timestamp.2013.11.06.10.29.44
+14 -3
View File
@@ -252,16 +252,27 @@
/* traps any LOADed form */ /* traps any LOADed form */
$('#' + target + ' form').each(function (i) { $('#' + target + ' form').each(function (i) {
var form = $(this); var form = $(this);
if(form.hasClass('no_trap')) {
return;
}
form.attr('data-w2p_target', target); form.attr('data-w2p_target', target);
if(!form.hasClass('no_trap')) { var url;
if(form.hasClass('trap_use_form_action')) {
/* submit using form own action, instead of component url */
url = form.attr('action');
} else {
/* should be there by default */ /* should be there by default */
url = action;
}
form.submit(function (e) { form.submit(function (e) {
web2py.disableElement(form.find(web2py.formInputClickSelector)); web2py.disableElement(form.find(web2py.formInputClickSelector));
web2py.hide_flash(); web2py.hide_flash();
web2py.ajax_page('post', action, form.serialize(), target, form); web2py.ajax_page('post', url, form.serialize(), target, form);
e.preventDefault(); e.preventDefault();
}); });
}
}); });
}, },
ajax_page: function (method, action, data, target, element) { ajax_page: function (method, action, data, target, element) {
+14 -3
View File
@@ -252,16 +252,27 @@
/* traps any LOADed form */ /* traps any LOADed form */
$('#' + target + ' form').each(function (i) { $('#' + target + ' form').each(function (i) {
var form = $(this); var form = $(this);
if(form.hasClass('no_trap')) {
return;
}
form.attr('data-w2p_target', target); form.attr('data-w2p_target', target);
if(!form.hasClass('no_trap')) { var url;
if(form.hasClass('trap_use_form_action')) {
/* submit using form own action, instead of component url */
url = form.attr('action');
} else {
/* should be there by default */ /* should be there by default */
url = action;
}
form.submit(function (e) { form.submit(function (e) {
web2py.disableElement(form.find(web2py.formInputClickSelector)); web2py.disableElement(form.find(web2py.formInputClickSelector));
web2py.hide_flash(); web2py.hide_flash();
web2py.ajax_page('post', action, form.serialize(), target, form); web2py.ajax_page('post', url, form.serialize(), target, form);
e.preventDefault(); e.preventDefault();
}); });
}
}); });
}, },
ajax_page: function (method, action, data, target, element) { ajax_page: function (method, action, data, target, element) {
+14 -3
View File
@@ -252,16 +252,27 @@
/* traps any LOADed form */ /* traps any LOADed form */
$('#' + target + ' form').each(function (i) { $('#' + target + ' form').each(function (i) {
var form = $(this); var form = $(this);
if(form.hasClass('no_trap')) {
return;
}
form.attr('data-w2p_target', target); form.attr('data-w2p_target', target);
if(!form.hasClass('no_trap')) { var url;
if(form.hasClass('trap_use_form_action')) {
/* submit using form own action, instead of component url */
url = form.attr('action');
} else {
/* should be there by default */ /* should be there by default */
url = action;
}
form.submit(function (e) { form.submit(function (e) {
web2py.disableElement(form.find(web2py.formInputClickSelector)); web2py.disableElement(form.find(web2py.formInputClickSelector));
web2py.hide_flash(); web2py.hide_flash();
web2py.ajax_page('post', action, form.serialize(), target, form); web2py.ajax_page('post', url, form.serialize(), target, form);
e.preventDefault(); e.preventDefault();
}); });
}
}); });
}, },
ajax_page: function (method, action, data, target, element) { ajax_page: function (method, action, data, target, element) {