First thxs both  but it is not what I want try to do.

I want to keep default button "Save, save and contine and Cancel" like usual.
With velocity I added a button  to update my class object on my page and 
redirect to another one. My button working well in view mode but I want to use 
it in edit mode, then I must save my page before my class object update and 
redirection if not all page modifications will be lost.

My main problem if I rewrite my code in JS is that I can not update my class 
object field attached on my page.

(It's a shame it doesn't exist an $xwiki.LaunchSaveCurrentPage)

Can I launch "save page" with javascript? My idea: i launch save my page in JS 
from edit mode to view mode with param (do redirect on another page). With this 
way I can keep my nice existant velocity code.
Do you know how if I can launch "save page" in JS then?
I see that a submit in JS go to preview mode, maybe I must modify the action 
target of #inline before submit? 




--- En date de : Lun 5.10.15, Eduard Moraru <[email protected]> a écrit :

> De: Eduard Moraru <[email protected]>
> Objet: Re: [xwiki-users] How to add a button with confirmation to save my     
> page?
> À: "XWiki Users" <[email protected]>
> Date: Lundi 5 octobre 2015, 17h35
> 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/xwiki-platform-web/src/main/webapp/resources/js/xwiki/actionbuttons/actionButtons.js
> [2]
> http://platform.xwiki.org/xwiki/bin/view/DevGuide/JavaScriptAPI#HBridgingcustomXWikieventsbetweenPrototypeandjQuery
> 
> 
> 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
> >
> _______________________________________________
> users mailing list
> [email protected]
> http://lists.xwiki.org/mailman/listinfo/users
> 
_______________________________________________
users mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/users

Reply via email to