Refresh page on successful form submission; and response.flash?

2,719 views
Skip to first unread message

Alec Taylor

unread,
Mar 20, 2013, 2:10:01 AM3/20/13
to web2py mailing-list
(I'm using SQLFORM)

Currently all I get is my `response.flash` message and the URL changes
from: "http://localhost/foo/1" to "http://localhost/foo/1#".

Instead I want the whole page to refresh so the changes the user made
propagates.

I do not want to use LOAD.

How do I refresh the page on successful form submission?

Thanks for all suggestions,

Alec Taylor

Niphlod

unread,
Mar 20, 2013, 4:49:26 AM3/20/13
to web...@googlegroups.com
if you're not using load the page refreshes entirely after a submission.
the behaviour now is to redirect to #, so you see the "switch" from /foo/1 to /foo/1# .
Inspect it with your preferred "developers tools", you'll see a POST and a redirect

webpypy

unread,
May 27, 2013, 10:07:38 AM5/27/13
to web...@googlegroups.com
Hi,

I am having similar situation.

It seems that after submission, "the menu" is not refreshed.

My question is " what is the command for refreshing the menu"? the same effect of F5

regards,

Ashraf

Niphlod

unread,
May 27, 2013, 10:31:24 AM5/27/13
to web...@googlegroups.com
a normal form reloads the page entirely (as if you push f5). If you're fiddling with ajax, then of course the entire page is not reloaded, but if you need that kind of functionality switch to a normal form handling.

webpypy

unread,
May 27, 2013, 10:49:38 AM5/27/13
to web...@googlegroups.com
Thank you Niphlod,

no ajax.

let me rephrase my question, I have a button, once clicked, I have to do things before defining the url of the controller.

Doing these things in the beginning of the controller means after the refreshing.

I hope my English is not very much confusing.

regards,

Ashraf

Anthony

unread,
May 27, 2013, 11:53:29 AM5/27/13
to web...@googlegroups.com
You can update the response.menu object wherever you want.

Anthony

webpypy

unread,
May 27, 2013, 12:19:48 PM5/27/13
to web...@googlegroups.com
Thank you, Anthony.

my question is " where ".

what is the location , in which the response.menu can be updated, after clicking the button and before defining the url (controller) of the button ?

in other words,where  can I write commands , that will be executed after the button is clicked and before executing the controller?

if i write these commands in the beginning of the controller, these commands will be executed after the refresh, but i need them executed before the refresh, and after the button is clicked.

I understand that button is defined in the view with the url of the controller,
is it possible to write something in between?


Regards,

Ashraf

Anthony

unread,
May 27, 2013, 12:22:34 PM5/27/13
to web...@googlegroups.com
Sorry, it's not at all clear to me what you are asking. Perhaps you can show some code and explain the exact workflow to clarify.

Anthony

webpypy

unread,
May 27, 2013, 1:14:04 PM5/27/13
to web...@googlegroups.com
ok, let me try again.

my description of a normal scenario:
i have a view displaying list of rows. there is a button (link) for each row. The link is pointing to a controller, which is related to a second view.
once the button(link) is clicked, the controller will start and show the second view. ( the menu is also refreshed).

what i am trying to do is:
change the menu, based on the selected row (clicked button).

Where do i write these changes?

when:
This needs to be done after the button clicking and before the start of the controller .

I did:
changing the menu in the beginning of the controller definition will not be reflected in the menu, because at that time, it has been refreshed already and to see the change, a manual f5 refresh is required.

I am trying to do the menu change before the refresh, so i will not need to refresh using f5.

Thank you for your patience.

Ashraf

webpypy

unread,
May 27, 2013, 4:14:46 PM5/27/13
to web...@googlegroups.com
To Anthony , Niphlod and Massimo :

I am asking for an answer to my question.

But, Now I have a different question.

Is my question valid? or am i making myself clear?

Regards,

Ashraf


Niphlod

unread,
May 27, 2013, 4:36:23 PM5/27/13
to web...@googlegroups.com
I didn't understand what you need.
if you need to update "just the menu", then you HAVE to do it in ajax (and "by hand", there's no web2py facility to change just the menu portion).
If instead you want a page reload, than the normal link should provide exactly what you need.....at most, once you click on the grid and you're redirected to the second controller, if you need to adjust the menu inside it you can issue a redirect(URL('anothercontroller')) alltogether.

Maybe if you can post the "workflow" with a simple example on the behaviour you'd like, it would be more understandable.

webpypy

unread,
May 27, 2013, 5:01:29 PM5/27/13
to web...@googlegroups.com
Thank you, Niphlod.

As you said,I created an extra controller, who solved my problem.

 
Regards,

Ashraf


Reply all
Reply to author
Forward
0 new messages