[xwiki-users] How to add a button with confirmation to save my page?
Hi, I have my application with MyClass, MySheet and MyTemplate. When I have a new page (based on MySheet/Class), in edit mode I can modify all my fields of Myclass Object but I want to add a button to save my page after confirmation... For the moment I have a button to redirect in a new page BUT I want to save current page before redirect if the user agreed a confirmation box. More precisely on my nice appli, on new page in edit mode, I have standard Save, Save and continue and cancel button and I want another one to ask on clik: "are you sure to save current fields modified on current page and open this another page"? - if yes save current page, add a value in a field with velocity and save and redirect to another one. - if No stay in edit mode Do you have a way to recommend? (perhaps I must try $('#form').submit(function() { with jquery) but I don't know if this save my page? Thxs for any help. Pascal B.
I think the Save action supports an 'xredirect' parameter. So if your form has a hidden input field with name='xredirect' then the user will be redirected to the specified URL after the page is saved. So what you can do is: * catch the click event on the button * ask for confirmation https://developer.mozilla.org/en-US/docs/Web/API/Window/confirm * cancel/prevent the event if no, set the value of the 'xredirect' parameter otherwise Hope this helps, Marius On Mon, Oct 5, 2015 at 5:35 PM, Pascal BASTIEN <[email protected]> wrote:
Hi,
I have my application with MyClass, MySheet and MyTemplate. When I have a new page (based on MySheet/Class), in edit mode I can modify all my fields of Myclass Object but I want to add a button to save my page after confirmation...
For the moment I have a button to redirect in a new page BUT I want to save current page before redirect if the user agreed a confirmation box.
More precisely on my nice appli, on new page in edit mode, I have standard Save, Save and continue and cancel button and I want another one to ask on clik: "are you sure to save current fields modified on current page and open this another page"? - if yes save current page, add a value in a field with velocity and save and redirect to another one. - if No stay in edit mode
Do you have a way to recommend? (perhaps I must try $('#form').submit(function() { with jquery) but I don't know if this save my page?
Thxs for any help.
Pascal B.
_______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
Hi, You might want to have a look at the javascript [1] events that are thrown when pressing the standard save / save & continue buttons that you might want to catch and insert a confirmation to the user. Depending on the user's answer, you can either cancel the event or modify the dom (to add some xredirect input) then let the event finish. Hope this helps, Eduard P.S.: remember to use the event bridge module [2] to be able to listen to PrototypeJS events from jQuery. ---------- [1] https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwik... [2] http://platform.xwiki.org/xwiki/bin/view/DevGuide/JavaScriptAPI#HBridgingcus... On Mon, Oct 5, 2015 at 6:08 PM, Marius Dumitru Florea < [email protected]> wrote:
I think the Save action supports an 'xredirect' parameter. So if your form has a hidden input field with name='xredirect' then the user will be redirected to the specified URL after the page is saved. So what you can do is:
* catch the click event on the button * ask for confirmation https://developer.mozilla.org/en-US/docs/Web/API/Window/confirm * cancel/prevent the event if no, set the value of the 'xredirect' parameter otherwise
Hope this helps, Marius
On Mon, Oct 5, 2015 at 5:35 PM, Pascal BASTIEN <[email protected]> wrote:
Hi,
I have my application with MyClass, MySheet and MyTemplate. When I have a new page (based on MySheet/Class), in edit mode I can modify all my fields of Myclass Object but I want to add a button to save my page after confirmation...
For the moment I have a button to redirect in a new page BUT I want to save current page before redirect if the user agreed a confirmation box.
More precisely on my nice appli, on new page in edit mode, I have standard Save, Save and continue and cancel button and I want another one to ask on clik: "are you sure to save current fields modified on current page and open this another page"? - if yes save current page, add a value in a field with velocity and save and redirect to another one. - if No stay in edit mode
Do you have a way to recommend? (perhaps I must try $('#form').submit(function() { with jquery) but I don't know if this save my page?
Thxs for any help.
Pascal B.
_______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
participants (3)
-
Eduard Moraru -
Marius Dumitru Florea -
Pascal BASTIEN