I think I just came up with a stupid simple way to do this. Just hide the
regular submit button and trigger("click") on it when the other button is
pressed. What do you think?
On Monday, November 10, 2014 1:25:49 PM UTC-8, weheh wrote:
>
> I wish to create an ajax button that is outside the <form> ... </form>
> created by SQLFORM.factory, such that when I click the ajax button it will
> self-submit the form. Is this possible?
>
> For instance
>
> def mytest():
> form=SQLFORM.factory(Field("mytext","text", requires=IS_NOT_EMPTY()))
> # add some form.element stuff to remove the submit button or make a
> custom form in the view, sans the submit button
> if form.process().accepted:
> # do stuff with form.vars.mytext or some such
> else:
> # blah blah
> return dict(form=form)
>
>
> # but in my view there is
> {{=form}}
> {{# some more stuff}}
> {{# finally the button that does the magic of submitting the form}}
> {{= TAG.BUTTON("click me", _onclick="ajax something or other")}}
>
>
> such that the "click me" button submits the form. What does the onclick
> function look like such that it submits the form as if the original form
> submit button was working its usual magic?
>
--
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.