I manage to launch save process of my page but I didn't manage to pass parameter in
this process :-(
On my page in edit mode, I add a button with this JS code:
function SaveCurrentPage(MyForm, MyParam) {
  require(['jquery'], function ($) {
$('#inline').attr('action','/bin/save/FormSMQ/SMQ-M2-FAM-Mon+am%C3%A9lioration');
  //$('#inline').attr('method','get');
  $('#inline').submit();
  });
};
this code save current page and go in the view mode BUT I can NOT pass some parameters to
my velocity code and update myClass object :-(
In the other way when I submit to view mode with
$('#inline').attr('action','/bin/view/FormSMQ/SMQ-M2-FAM-Mon+am%C3%A9lioration');
My current page is NOT saved but I can pass some parameter with hidden input (I can catch
them with $request.aaaa in velocity code)
--- En date de : Mar 6.10.15, Marius Dumitru Florea <mariusdumitru.florea(a)xwiki.com>
a écrit :
  De: Marius Dumitru Florea
<mariusdumitru.florea(a)xwiki.com>
 Objet: Re: [xwiki-users] Fw : Re: How to add a button with confirmation to save my page?
 À: "XWiki Users" <users(a)xwiki.org>
 Date: Mardi 6 octobre 2015, 12h23
 On Tue, Oct 6, 2015 at
 1:01 PM, Pascal BASTIEN <pbasnews-xwiki(a)yahoo.fr>
 wrote:
  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?
 The submit button name (e.g.
 name="action_save") is not included by
 default when you submit the form using
 JavaScript (because the form
 may have
 multiple submit buttons, like in your case, and the
 JavaScript code wouldn't know what button
 to indicate in the submit
 form unless you
 explicitly indicate it). You need to add the button
 name to the submit parameters when you make the
 AJAX save request.
 Hope
 this helps,
 Marius