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 Beller wrote:
>
> 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
> correct? should I not use the Bootstrap js?
>
> Here's my function:
> $('#note-form').submit(function(e) {
> e.preventDefault();
> $form= $(this);
> $.post("/app/controller/action.json",
> {formdata: $form.serialize(),
> note_id: $('#note-id').val(),
> note_text: $('#note-text').val()
> },
> function(data) {
> $('#form-feedback').html(data.notes).fadeIn(500);
> $form[0].reset();
> }
> );
> });
>
>
> On Wednesday, August 13, 2014 4:29:47 PM UTC-4, Niphlod wrote:
>>
>> 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 13, 2014 8:52:25 PM UTC+2, Michael Beller wrote:
>>>
>>> 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 input elements disabled during form submission
>>> disableSelector: 'input, button, textarea, select',
>>> // Form input elements re-enabled after form submission
>>> enableSelector: 'input:disabled, button:disabled,
>>> textarea:disabled, select:disabled',
>>>
>>> Have either of you found a solution?
>>>
>>> On Sunday, August 3, 2014 2:53:50 PM UTC-4, Reza Amindarbari wrote:
>>>>
>>>> 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, the button greys out.
>>>>>
>>>>> Here is the model:
>>>>>
>>>>> db.define_table('t_post',
>>>>> Field('f_post', type='text',
>>>>> label=T('Post')),
>>>>> auth.signature,
>>>>> format='%(f_post)s')
>>>>>
>>>>> Here are my controller functions.
>>>>>
>>>>> def ajax_post():
>>>>> posts = crud.select(db.t_post, fields=['f_post'], query =
>>>>> db.t_post.created_by == auth.user,
>>>>> headers={'t_post.f_post': 'Post'}, orderby =
>>>>> ~db.t_post.created_on)
>>>>> search = crud.search(db.t_post)
>>>>> return dict(posts=posts, search=search)
>>>>>
>>>>> def new_post():
>>>>> postdata = request.vars.post
>>>>> db.t_post.insert(f_post = postdata)
>>>>> posts = crud.select(db.t_post, fields=['f_post'], query =
>>>>> db.t_post.created_by == auth.user,
>>>>> headers={'t_post.f_post': 'Post'}, orderby =
>>>>> ~db.t_post.created_on)
>>>>> return posts
>>>>>
>>>>> Here is the model:
>>>>>
>>>>> {{extend 'layout.html'}}
>>>>> <h1>This is the default/ajax_post.html template</h1>
>>>>> <form onsubmit="return false">
>>>>> <div>Post : <input name="post"/></div>
>>>>> <div><button onclick="ajax('new_post', ['post'],'results')">Post
>>>>> Message</button></div>
>>>>> </form>
>>>>> <div id="results">
>>>>> {{=posts}}
>>>>> </div>
>>>>> <div>
>>>>> {{=search[0]}}
>>>>> </div>
>>>>>
>>>>> At first I used an input field with type "submit" for the submit
>>>>> button. When that happened, it would
>>>>> grey out and the value would set to "Working....". At least now
>>>>> button text doesn't change, but it
>>>>> it still grey's out. Inspecting the element in Firefox I get:
>>>>>
>>>>> <button value="Working..." class="btn disabled"
>>>>> onclick="ajax('new_post', ['post'],'results')">Post Message</button>
>>>>>
>>>>> Why? I didn't ask it to change the button's class to disabled. And
>>>>> it stays greyed even though
>>>>> the results have returned and my "results" div has been properly
>>>>> updated. I can still click on
>>>>> the button, but it just appears disabled.
>>>>>
>>>>
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.