[web2py] Re: Strange ajax problem

2014-08-15 Thread Cliff Kachinske
Michael, one final thought. To get a better handle on what's going on, in Chrome or Firefox press F12 to bring up the developer tools. Click the Network tab and play around with submitting your forms. You can look at the entire conversation. On Friday, August 15, 2014 8:55:41 AM UTC-4, Michae

[web2py] Re: Strange ajax problem

2014-08-15 Thread Michael Beller
Perfect - I can't thank you enough! I saw the code in index right after I sent my other message, I was looking for display_page. Not sure what I did wrong last night (probably just a case of staring at code too long) but I see how you added the $.web2py.enableElement. I just went back and read

[web2py] Re: Strange ajax problem

2014-08-15 Thread Leonel Câmara
I used default/index.html, return_data doesn't need a view as it uses generic.json -- 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 mess

Re: [web2py] Re: Strange ajax problem

2014-08-15 Thread Michael Beller
Don't be sorry! Thanks but I don't see any views in the package - I see your two functions at the bottom of the default controller but no corresponding views. Did I miss them? On Fri, Aug 15, 2014 at 8:25 AM, Leonel Câmara wrote: > I'm sorry I wasn't testing any of this. Have a working exampl

[web2py] Re: Strange ajax problem

2014-08-14 Thread Michael Beller
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 woul

[web2py] Re: Strange ajax problem

2014-08-14 Thread Leonel Câmara
Using your jquery post code or web2py's ajax functiong 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', '#my

[web2py] Re: Strange ajax problem

2014-08-14 Thread Michael Beller
Thanks Leonel - awesome explanation. I looked through your code that you posted to load forms in modals and handle file uploads - I need to study more. One question - you say below "you're using web2py's ajax convenience function which doesn't care about what it's doing" - I'm actually not usi

[web2py] Re: Strange ajax problem

2014-08-14 Thread Leonel Câmara
In a jquery event handler returning false is the same as calling event.preventDefault and event.stopPropagation that's why you don't get the Working... anymore, you are stopping web2py.js handlers for submission from being processed. Namely this one: $(doc).on('submit', 'form', function (

[web2py] Re: Strange ajax problem

2014-08-14 Thread Michael Beller
Thanks Limedrop and Cliff, I found something that appears to work but I don't understand why. I re-read the web2py book and noticed in: http://www.web2py.com/books/default/chapter/29/11/jquery-and-ajax#Ajax-form-submission that the following line was added at the end of the submit handling fun

[web2py] Re: Strange ajax problem

2014-08-14 Thread Cliff Kachinske
Aha, I get what you're doing now. Maybe the simple answer is don't use a submit button. Try something like You may have to mess around with the css a bit to get the vertical alignment and height right. This will work around the client side handlers. On Thursday, August 14, 2014 4:20:05 PM

[web2py] Re: Strange ajax problem

2014-08-14 Thread Limedrop
You might want to check out the javascript that Leonel submitted here: https://groups.google.com/d/msg/web2py/JFy3BCHXgYc/7npKiqs6BOUJ In particular see how he uses: $.web2py.disableElement(form.find($.web2py.formInputClickSelector)); On Friday, August 15, 2014 8:20:05 AM UTC+12, Michael Be

[web2py] Re: Strange ajax problem

2014-08-14 Thread Michael Beller
Thanks Cliff and Niphlod, I've used ajax several times and think I understand the process. My problem now involves using a form inside a bootstrap modal and using ajax to submit the form. What I meant by "web2py intercepting" the event was that web2py.js registers an event handler for the sub

[web2py] Re: Strange ajax problem

2014-08-13 Thread Cliff Kachinske
Here's how I do it and I assume Web2py does something similar when it, for example, resets the "Working" caption on buttons. The Javascript/Jquery whatever in the client changes the state of the button. I do it before sending the ajax post. I don't know how Web2py does it. It doesn't matter wh

[web2py] Re: Strange ajax problem

2014-08-13 Thread Michael Beller
Thanks ... Niphlod - I'll try to create a minimal app to reproduce. Cliff - are you suggesting to use the web2py ajax function rather the jQuery post? I'm also trying to understand why web2py is intercepting the event and why it doesn't think the response is succesful which I assume is why the

[web2py] Re: Strange ajax problem

2014-08-13 Thread Cliff Kachinske
get rid of the target in your ajax call and use ':eval' instead. Then reset the button in your response. On Sunday, May 4, 2014 9:33:05 AM UTC-4, John Drake wrote: > > I've created a simple ajax form to update a "post" database. For some > strange reason when I post a new message, the button gr

[web2py] Re: Strange ajax problem

2014-08-13 Thread Niphlod
you can use whatever you like it just needs to accomodate how web2py handles ajax. Without a complete example I can't tell what's going wrong with your own implementation. If you can, pack a minimal app to reproduce the behaviour On Wednesday, August 13, 2014 10:50:54 PM UTC+2, Michael Belle

[web2py] Re: Strange ajax problem

2014-08-13 Thread Michael Beller
Thanks Niphlod, I'm not using inline JS or explicitly using web2py.js. I'm using a Bootstrap Modal pretty much verbatim from the Bootstrap examples. It appears that web2py js is capturing the submit and disabling the button but not detecting the response and enabling the submit - is that corr

[web2py] Re: Strange ajax problem

2014-08-13 Thread Niphlod
the logic behind is suppressing double submission. web2py disables the submit button when you click on it until a proper response is returned. Don't EVER use inline javascript, and don't use web2py.js internal functions without proper knowledge of the inner workings :-P On Wednesday, August 1

[web2py] Re: Strange ajax problem

2014-08-13 Thread Michael Beller
I just encountered the same problem. I'm using a Bootstrap Modal form and encountering the same problem - the form sends and receives data via AJAX but then adds the 'disabled' class to the button. I found this logic in web2py.js but I'm not clear on what's happening and why: // Form inpu

[web2py] Re: Strange ajax problem

2014-08-03 Thread Reza Amindarbari
Did you figure out what was wrong? I faced the same issue. Everything works fine when I take out the ajax function. On Sunday, May 4, 2014 9:33:05 AM UTC-4, John Drake wrote: > > I've created a simple ajax form to update a "post" database. For some > strange reason when I post a new message, th