On Tuesday, February 28, 2017 at 3:37:51 PM UTC-5, Andrea Fae' wrote:
>
> I have this code in a view (from a select funcion javascript)
>
>
> $.get('{{=URL('default','nuovo_evento')}}',{risorsa:eventData.resourceId,titolo:eventData.title,start:start,end:end});
>
First, you are passing data via the Ajax request, but you don't do anything
with that data in the controller. Second, the above code does not do
anything with the returned response, so you won't see any changes on the
page. Your controller returns some HTML, so you'll have to use JS to insert
that HTML somewhere in the page.
> this code call a controller
>
> def nuovo_evento():
> form=crud.create(db.evento)
> return locals()
>
> this is the view very simple
> {{extend 'layout.html'}}
> {{=form}}
>
If you intend to load the HTML for this form somewhere in the page, you
probably don't want to extend layout.html, as you will get the entire UI
nested inside the page.
Also, note that unless you intercept the form submission via JS and submit
the form via Ajax, submitting the form will cause the entire page to reload
with the output of the nuovo_evento controller.
I suggest you read
http://web2py.com/books/default/chapter/29/11/jquery-and-ajax#The-ajax-function
and
http://web2py.com/books/default/chapter/29/12/components-and-plugins#Components--LOAD-and-Ajax,
and in particular, if you want to load a form in a page via Ajax, use an
Ajax component (i.e., LOAD(..., ajax=True)).
Anthony
--
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.