On Wednesday, May 9, 2012 6:23:53 PM UTC-4, sebastian wrote:
>
> the ajax_trap=True fixed the form which nows call search_bar... but 
> redirect(URL('services', vars={'qry':form.vars.qry}))  is rendered inside 
> the component....
>
> What I'm trying to do, is to include a simple form in the layout.html that 
> calls a function (as it is now, with the ajax_trap trick), and if it is not 
> empty, it will redirect to a different page (loading the whole page)....
>

If you want an Ajax request to result in a redirect of the whole page, you 
have to do it via Javascript after the Ajax response arrives. You could add 
something like this to the search_bar function:

    if [some condition]:
        form = SCRIPT('jQuery(function() {location = "%s"})' %
            URL('default', 'services', vars=dict(qry=form.vars.qry),extension
=False))

That will replace the form with a script that changes the window location 
to the desired URL. Note, in the URL() function, extension is set to False 
-- otherwise, if the component happens to have the .load extension, that 
extension will propagate to the services URL -- setting extension to False 
simply leaves the extension off (in which case, it will look for the .html 
view).

Anthony

Reply via email to