I was just thinking, would it not be smarter to have a FORM helper with an 
ajax option?

something like this:

FORM(ajax=True, eval=True, target='targetdiv/object')

To be honest almost half of my form posts are ajax now, so it feels wiered 
that I can not just choose if it is ajax when creating the form with the 
FORM helper. And the reason I do not do it more is because of the overhead 
and complexity of the code that increases for every form I need to write. I 
would even like to have a crud.create form that I could choose as an ajax 
form reducing ajax forms to a couple of lines of code in my controler 
instead of writing them in the view.

cheers and thanks!


On Saturday, May 11, 2013 5:18:13 PM UTC+8, Mika Sjöman wrote:
>
> that one worked like a charm. Final solution became like this, where the 
> submit buttons is kind of there just for looks since it will send onkeyUp.
>
> What I really like about it is that It reduces the JQuery to zero for my 
> part to write which means less code to manage.
>
> -----SOLUTION ---
>
> <form id="update_phone_number" action="#">
>                 Mobile Phone:
>                 <input name="phone" 
> onkeyup="ajax('{{=URL('update_phone_number')}}', ['phone'], ':eval')" />
>                 <input type="submit" 
> onClick="ajax('{{=URL('update_phone_number')}}', ['phone'], ':eval')" 
> value="Add phone number" class="btn btn-success"/>
> </form>
>
>
>
> On Friday, May 10, 2013 7:26:40 PM UTC+8, Anthony wrote:
>>
>> http://web2py.com/books/default/chapter/29/11#Eval-target
>>
>> On Friday, May 10, 2013 6:13:23 AM UTC-4, Mika Sjöman wrote:
>>>
>>> Hi
>>>
>>> No I am not calling it from a component, but from a jQuery post when I 
>>> submit a phone number from a post via ajax.
>>>
>>> Any ideas?
>>>
>>> On Friday, May 10, 2013 2:49:33 PM UTC+8, Niphlod wrote:
>>>>
>>>> if you're using components, use response.js .....
>>>> http://web2py.com/books/default/chapter/29/12?search=response.js
>>>>
>>>> On Friday, May 10, 2013 7:10:31 AM UTC+2, Mika Sjöman wrote:
>>>>>
>>>>> Hi
>>>>>
>>>>> I am trying to close a window title dialog with JQUERY after 
>>>>> sucessuflly updating a clients phone number. The problem is that after I 
>>>>> successfully update the data I send this as a response to the browser: 
>>>>>
>>>>> ....
>>>>> message = "jQuery('#windowTitleDialog').toggle('slow');"
>>>>> return message
>>>>>
>>>>>
>>>>> But the script just loads it as text in a DIV instead of executing the 
>>>>> Jquery :( 
>>>>>
>>>>> The way I call it is like this from the webbrowser:
>>>>>
>>>>> <script>
>>>>>                 jQuery('#update_phone_number').submit(function() {
>>>>>                   ajax('{{=URL('update_phone_number')}}', ['phone',], 
>>>>> 'phone_updated_div');
>>>>>                   return false;
>>>>>                 });
>>>>>  </script>
>>>>>
>>>>> Anyone has an idea on how to run the JQUERY instead of just loding it 
>>>>> as text inside the phone_updated_div ?
>>>>>
>>>>> cheerio
>>>>>
>>>>

-- 

--- 
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