Thanks Leonel, I tried both options but couldn't get them to work - or at least I haven't found the right combination.
I also created a simple ajax form using the example in the book to apply your two recommendations. I could only get it to work with the 'return false' statement but that would not disable the button to prevent double submission. If I remove the 'return false' statement, the button shows 'working ...' but the target is not updated. I'm still trying to learn what's happening so thanks for your explanations. {{extend 'layout.html'}} <div id="target"></div> <form id="myform"> <input name="your_message" id="your_message" /> <input type="submit" /> </form> <script> jQuery('#myform').submit(function() { ajax('{{=URL('new_post')}}', ['your_message'], 'target'); //return false; }); </script> On Thursday, August 14, 2014 10:54:19 PM UTC-4, Leonel Câmara wrote: > > Using your jquery post code or web2py's ajax function would give you the > same problem with the button that you're preventing with return false. > > Basically, if you want you can just remove return false from your submit > handler and add this to your javascript: > > $(document).on('ajax:complete', '#myForm', function (e) { > $.web2py.enableFormElements($(this)); > }); > > replacing myForm with your form's id and have it working. > > Another option is to not put that javascript and simulate a trapped form > by setting data-w2p_target which will make web2py.js form_handlers fire as > they will think it's a trapped form: > > <form class="form-horizontal" id="note-form" data-w2p_target> > > > I think either option will work (I'm not testing this). So: > 1. Remove return false > 2. Either add the javascript or the data-w2p_target attribute to the form. > 3. ??? > 4. Profit! > > -- 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/d/optout.