Correction/patch for web2py.js trap_form function.

15 views
Skip to first unread message

Ide

unread,
Sep 16, 2014, 11:57:22 AM9/16/14
to web...@googlegroups.com
I have spotted a scenario where the web2py.js trap_form function does not work correctly.


Currently looks like this:
    var url = form.attr('action');

   
if ((url === "") || (url === "#")) {
     
/* form has no action. Use component url. */
      url
= action;
   
}

Hoever, if the form has no attribute called action then the url variable is not defined, which the if statement does not test for.

Can I suggest this code needs changing to the following:

    var url = form.attr('action');

   
if ((url === "") || (url === "#") || (typeof url === 'undefined')) {
     
/* form has no action. Use component url. */
      url
= action;
   
}

Now if the query to get the action attribute of the form return undefined, this will be recognised and the component's url used instead.

Regards.
Reply all
Reply to author
Forward
0 new messages