From 58c22b8ed0c463aed5907d4e7bce025f905d52ed Mon Sep 17 00:00:00 2001 From: mdipierro Date: Wed, 6 Nov 2013 16:57:33 -0600 Subject: [PATCH] synced web2py.js, thanks Vinicius --- VERSION | 2 +- applications/admin/static/js/web2py.js | 16 ++++++++-------- applications/examples/static/js/web2py.js | 16 ++++++++-------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/VERSION b/VERSION index 8a8f833f..e8f36bd2 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.7.4-stable+timestamp.2013.11.06.11.14.11 +Version 2.7.4-stable+timestamp.2013.11.06.16.56.35 diff --git a/applications/admin/static/js/web2py.js b/applications/admin/static/js/web2py.js index 3c8b568a..e714d3cc 100644 --- a/applications/admin/static/js/web2py.js +++ b/applications/admin/static/js/web2py.js @@ -250,22 +250,20 @@ }); }, + trap_form: function (action, target) { /* traps any LOADed form */ $('#' + target + ' form').each(function (i) { var form = $(this); - if(form.hasClass('no_trap')) { + if (form.hasClass('no_trap')) { return; } form.attr('data-w2p_target', target); - var url; + var url = form.attr('action'); - 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 */ + if ((url === "") || (url === "#")) { + /* form has no action. Use component url. */ url = action; } @@ -275,8 +273,10 @@ web2py.ajax_page('post', url, form.serialize(), target, form); e.preventDefault(); }); - }); + }); }, + + ajax_page: function (method, action, data, target, element) { /* element is a new parameter, but should be put be put in front */ if(element == undefined) element = $(document); diff --git a/applications/examples/static/js/web2py.js b/applications/examples/static/js/web2py.js index 3c8b568a..e714d3cc 100644 --- a/applications/examples/static/js/web2py.js +++ b/applications/examples/static/js/web2py.js @@ -250,22 +250,20 @@ }); }, + trap_form: function (action, target) { /* traps any LOADed form */ $('#' + target + ' form').each(function (i) { var form = $(this); - if(form.hasClass('no_trap')) { + if (form.hasClass('no_trap')) { return; } form.attr('data-w2p_target', target); - var url; + var url = form.attr('action'); - 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 */ + if ((url === "") || (url === "#")) { + /* form has no action. Use component url. */ url = action; } @@ -275,8 +273,10 @@ web2py.ajax_page('post', url, form.serialize(), target, form); e.preventDefault(); }); - }); + }); }, + + ajax_page: function (method, action, data, target, element) { /* element is a new parameter, but should be put be put in front */ if(element == undefined) element = $(document);