"$.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);
var url = '{{=URL('default', 'org_form_load.load/org_code')}}';
$.web2py.component(url, 'org_form_target');
}

Note the URL is generated in Python, hence its inclusion within the {{...}} 
template delimiters.

Anthony

On Monday, December 30, 2013 3:58:10 PM UTC-5, Avi A wrote:
>
> 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 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). Then 
>>> call $.web2py.component() with that URL, and in the org_form_load action, 
>>> use request.args(0) instead of request.vars.name.
>>>
>>> Anthony
>>>
>>> On Monday, December 30, 2013 12:56:19 PM UTC-5, Avi A wrote:
>>>>
>>>> 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, 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 
>>>>>> 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 via an Ajax component:
>>>>>>
>>>>>> onkeyup="{{="$.web2py.component('%s', 'org_form_target');" % 
>>>>>> URL('default', 'org_form_load.load')}}"
>>>>>>
>>>>>> Anthony
>>>>>>
>>>>>> On Monday, December 30, 2013 12:18:33 PM UTC-5, Avi A wrote:
>>>>>>>
>>>>>>> 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 30, 2013 6:14:57 PM UTC+2, Anthony wrote:
>>>>>>>>
>>>>>>>> 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>
>>>>>>>>>    <input name="name" onkeyup="ajax('org_form_load.load', 
>>>>>>>>> ['name'], 'org_form_target')" />
>>>>>>>>> </div>
>>>>>>>>> <div id = "org_form_target"></div>
>>>>>>>>>
>>>>>>>>> and something like this on the controller:
>>>>>>>>>
>>>>>>>>> def org_form_load():
>>>>>>>>>     org_code = request.vars.name
>>>>>>>>>     org_code_name = db(......).select(..............)
>>>>>>>>>     if org_code_name:
>>>>>>>>>         db.t_org_members.f_org_member.default = auth.user.id
>>>>>>>>>         form = 
>>>>>>>>> SQLFORM(db.t_org_members,onupdate=auth.archive,submit_button= 
>>>>>>>>> 'something.......')
>>>>>>>>>         if form.process().accepted:
>>>>>>>>>             response.flash = 'Success!'
>>>>>>>>>         else:
>>>>>>>>>             response.flash = 'There was an error..'
>>>>>>>>>         return dict(form = form, org_code_name = org_code_name)
>>>>>>>>> and on the org_form_load:
>>>>>>>>>
>>>>>>>>> {{=form}}
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> (Before moving the form into the load page, everything went fine.)
>>>>>>>>> After moving the form to the load page, this is what it does:
>>>>>>>>> User fill correctly the organization code.
>>>>>>>>> The form appears as expected, (but not submitted yet)
>>>>>>>>> BUT I already get the " response.flash = 'There was an error..'".
>>>>>>>>> If I try to submit the form nothing flashes and form is not 
>>>>>>>>> submitted either.
>>>>>>>>> Help please...
>>>>>>>>> Thanks.
>>>>>>>>>
>>>>>>>>

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to