[web2py] Re: with ajax load, getting form failure alert before form was submitted

2013-12-31 Thread Avi A
Still stuck with that. While this is rendered as expected on w3school try me: (assuming org_code = 3): var a ={{=URL('default', 'org_form_load.load/ + org_code + ')}}; alert(a): {{=URL('default', 'org_form_load.load/3')}} on web2py it renders:

[web2py] Re: with ajax load, getting form failure alert before form was submitted

2013-12-31 Thread Anthony
It appears you are trying to mix Python and Javascript. Note, everything inside the {{...}} must be Python and gets executed on the server. Adding the org_code variable must be done in Javascript, so it would be: var url = '{{=URL('default', 'org_form_load.load')}}'; $.web2py.component(url +

[web2py] Re: with ajax load, getting form failure alert before form was submitted

2013-12-31 Thread Avi A
Now I got it... theoython {{ is rendered befor the js Thanks. On Wednesday, January 1, 2014 2:22:24 AM UTC+2, Anthony wrote: It appears you are trying to mix Python and Javascript. Note, everything inside the {{...}} must be Python and gets executed on the server. Adding the org_code

[web2py] Re: with ajax load, getting form failure alert before form was submitted

2013-12-30 Thread Anthony
The form is not accepted when it is first created, so you will always get that error message. Instead, you want: elif form.errors: response.flash = 'There was an error..' Anthony On Monday, December 30, 2013 10:21:58 AM UTC-5, Avi A wrote: Hi, I have this on the view: div

[web2py] Re: with ajax load, getting form failure alert before form was submitted

2013-12-30 Thread Avi A
Thanks, It solved the error getting after the form is loaded into the page, but still nothing happen if I submit the form. This is what I do: if form.process().accepted: response.flash = 'Success!' elif form.errors: response.flash = 'response errors' On Monday, December

[web2py] Re: with ajax load, getting form failure alert before form was submitted

2013-12-30 Thread Anthony
The form won't get submitted to the org_form_load action, but instead will get submitted to the action of the parent page. You have to trap the form submission and submit back to the org_form_load action. Rather than using the ajax() function to load a form, you're better off loading the form

[web2py] Re: with ajax load, getting form failure alert before form was submitted

2013-12-30 Thread Avi A
Thanks. I will look into it. Happy new year! and thanks for all the awesome support! On Monday, December 30, 2013 7:47:48 PM UTC+2, Anthony wrote: The form won't get submitted to the org_form_load action, but instead will get submitted to the action of the parent page. You have to trap the

[web2py] Re: with ajax load, getting form failure alert before form was submitted

2013-12-30 Thread Avi A
How is the name (input value) is passed in this component template/case? (i click the code and the form won't load into the page.). On Monday, December 30, 2013 7:49:32 PM UTC+2, Avi A wrote: Thanks. I will look into it. Happy new year! and thanks for all the awesome support! On Monday,

[web2py] Re: with ajax load, getting form failure alert before form was submitted

2013-12-30 Thread Anthony
Oops, sorry. You'll need to do something more sophisticated. Create an onkeyup handler that retrieves the value in the input and appends it to the URL of the form action (i.e., /default/org_form_load.load/some_name). Then call $.web2py.component() with that URL, and in the org_form_load action,

[web2py] Re: with ajax load, getting form failure alert before form was submitted

2013-12-30 Thread Avi A
ok thanks. On Monday, December 30, 2013 8:24:04 PM UTC+2, Anthony wrote: Oops, sorry. You'll need to do something more sophisticated. Create an onkeyup handler that retrieves the value in the input and appends it to the URL of the form action (i.e., /default/org_form_load.load/some_name).

[web2py] Re: with ajax load, getting form failure alert before form was submitted

2013-12-30 Thread Avi A
It works only till the alert... script function insert_component(org_code) { alert(org_code); $.web2py.component('%s', 'org_form_target'); % URL('default', 'org_form_load.load/org_code'); } /script On Monday, December 30, 2013 8:27:00 PM UTC+2, Avi A wrote: ok thanks. On Monday, December

[web2py] Re: with ajax load, getting form failure alert before form was submitted

2013-12-30 Thread Anthony
$.web2py.component('%s', 'org_form_target'); % URL('default', 'org_form_load.load/org_code'); is actually Python code that generates Javascript, so you cannot use it as you are using it. Instead, I would create the url variable separately: function insert_component(org_code) { alert(org_code);

[web2py] Re: with ajax load, getting form failure alert before form was submitted

2013-12-30 Thread Avi A
I was in the direction in one of the tries... Thanks. On Monday, December 30, 2013 11:17:44 PM UTC+2, Anthony wrote: $.web2py.component('%s', 'org_form_target'); % URL('default', 'org_form_load.load/org_code'); is actually Python code that generates Javascript, so you cannot use it as you