Hi selecta,
Thanks for the quick response... I was debugging with firebug and this is
what I got:
<input type="submit" value="Add">
so the type is correct... but I can't see the attribute... after I click on
submit I can see the "was_clicked_to_submit" appearing on firebug and then
it disappear...
on the view I'm using a custom form:
{{=form.custom.begin}}
Nome: <div>{{=form.custom.widget.produto}}
x: {{=form.custom.widget.quantidade}}
{{=form.custom.submit}}</div>
{{=form.custom.end}}
But nothing special...
Not sure what is happening... any idea? On your view you can see the
"was_clicked_to_submit" as soon as you load the forms?
*This is my controller:*
def adicionar_item():
compra_id=request.args[0]
form = SQLFORM.factory(
Field('produto', 'reference produto', requires=IS_NOT_EMPTY(),widget
= SQLFORM.widgets.autocomplete(request, db.produto.nome, id_field=
db.produto.id)),
#Field('produto', 'reference produto', requires=IS_NOT_EMPTY()),
Field('quantidade', 'integer',requires=IS_NOT_EMPTY()
,default=1),submit_button='Adicionar')
if form.accepts(request.vars, session, hideerror=True):
form.vars.id =
db.compra_produto.insert(produto=form.vars.produto,compra=compra_id,quantidade=form.vars.quantidade)
response.js = "ajax('%s', [], 'show_itemlist');"
%(URL(r=request,f='listar_itens.load',args=[compra_id]))
response.js += "ajax('%s', [], 'total_compra');"
%(URL(r=request,f='total_compra.load',args=[compra_id]))
response.flash = 'Produto inserido'
elif form.errors:
response.flash = 'Erro na inserção'
return dict(form=form)
On Sat, Apr 23, 2011 at 3:57 PM, selecta <[email protected]> wrote:
> what did not work? what is should do is add a click event to each
> submit button and add a special property onclick
> $("[type=submit],[type=image]", this).click(function(e){ $
> (this).attr("was_clicked_to_submit","YES"); });
> if the form is submitted it searches for that property
> (was_clicked_to_submit) and adds this element to the variable list, if
> you can it would be nice if you could debug it
> look in firebug/dragonfly/... if was_clicked_to_submit is an attribute
> of your submit button
> maybe your submit button has a different type??
>
>
> On Apr 23, 6:37 pm, Tito Garrido <[email protected]> wrote:
> > Hi selecta,
> >
> > I've tried your patch and didn't work for me... I'm having the same
> > problem... with 2 LOAD forms the submit behavior is intermitent.
> >
> > Regards,
> >
> > Tito
> >
> >
> >
> >
> >
> > On Sat, Apr 23, 2011 at 3:57 AM, Tito Garrido <[email protected]>
> wrote:
> > > Wow! I just posted a message about this problem... +1 !
> >
> > > I'm using 2 forms with LOAD on the same page and I got the same
> problem...
> > > it doesn't work on the first submit.
> >
> > > On Wed, Apr 13, 2011 at 5:12 PM, selecta <[email protected]>
> wrote:
> >
> > >> donehttp://code.google.com/p/web2py/issues/detail?id=232
> >
> > >> On Apr 11, 3:44 pm, Massimo Di Pierro <[email protected]>
> > >> wrote:
> > >> > No objection in principle but need to check implementation. Can you
> > >> > please open an issue on google code and upload your propose patch.
> > >> > Thanks.
> >
> > >> > Massimo
> >
> > >> > On Apr 7, 4:46 am, selecta <[email protected]> wrote:
> >
> > >> > > itsnt it annoying that when you have forms with multiple submit
> > >> > > buttons in a web2py component the button that is clicked to submit
> the
> > >> > > form is not submitted
> > >> > > here is a fix for web2py_ajax.html
> >
> > >> > > now you can have forms with 2 or more submit buttons/images in
> web2py
> > >> > > components
> >
> > >> > > diff -r 25822b3791e4 applications/welcome/views/web2py_ajax.html
> > >> > > --- a/applications/welcome/views/web2py_ajax.html Mon Apr 04
> > >> 14:48:36
> > >> > > 2011 -0500
> > >> > > +++ b/applications/welcome/views/web2py_ajax.html Thu Apr 07
> > >> 11:44:37
> > >> > > 2011 +0200
> > >> > > @@ -72,9 +72,12 @@
> > >> > > jQuery('#'+target+' form').each(function(i){
> > >> > > var form=jQuery(this);
> > >> > > if(!form.hasClass('no_trap'))
> > >> > > + $("[type=submit],[type=image]", this).click(function(e){
> > >> > > + $(this).attr("was_clicked_to_submit","YES");
> > >> > > + });
> > >> > > form.submit(function(obj){
> > >> > > jQuery('.flash').hide().html('');
> > >> > > - web2py_ajax_page('post',action,form.serialize(),target);
> > >> > > + web2py_ajax_page('post',action,form.serialize() + "&" +
> $
> > >> > > ("[was_clicked_to_submit=YES]").attr('name') + "=" + $
> > >> > > ("[was_clicked_to_submit=YES]").val(),target);
> > >> > > return false;
> > >> > > });
> > >> > > });
> >
> > > --
> >
> > > Linux User #387870
> > > .........____
> > > .... _/_õ|__|
> > > ..º[ .-.___.-._| . . . .
> > > .__( o)__( o).:_______
> >
> > --
> >
> > Linux User #387870
> > .........____
> > .... _/_õ|__|
> > ..º[ .-.___.-._| . . . .
> > .__( o)__( o).:_______
>
--
Linux User #387870
.........____
.... _/_õ|__|
..º[ .-.___.-._| . . . .
.__( o)__( o).:_______