SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a custom Submit button on a custom NewItem form. I have a JQuery function which I would like to run when this button is clicked.

I also need the GenFireServerEvent(('__commit;__redirect={/}')) action to run after my function if certain things happen in the function.

Ideally I'd like to just use the GenFireServerEvent(('__commit;__redirect={/}')) action in my function so I can specify when to perform the action, however when I try this I get the "GenFireServerEvent is not defined" error.

Is there an alternative for GenFireServerEvent(('__commit;__redirect={/}')) to use in JQuery functions?

share|improve this question
up vote 3 down vote accepted

GenFireServerEvent is not a JavaScript function. If you look under the hood in the DOM, you'll see it gets rendered into a completely different. e.g.

<A style="WIDTH: 10px; DISPLAY: inline-block; HEIGHT: 10px" href="javascript: __doPostBack('ctl00$m$g_9254a69e_0546_4c53_ba5d_c155337d00e3$ctl02','__cancel;dvt_form_key={-1}')"><IMG style="POSITION: absolute; TOP: -128px !important; LEFT: 0px !important" border=0 alt=New src="/_layouts/images/fgimg.png"></A>

What you can do though, in your form's code is wrap the GenFireServerEvent with an if statement. This is a common task especially when using the PreSaveAction function. Here's an example:

<input type="button" value="Save" name="btnSave" onclick="javascript: if( PreSaveAction() ) {ddwrt:GenFireServerEvent('__commit')}" />

Hope this helps!

share|improve this answer

Other solution, You can call the other function with other click using jquery, you need add an id for your input button.

 <input id="custom" type="button" value="Save" name="btnSave" onmousedown="javascript: if( PreSaveAction() ) {ddwrt:GenFireServerEvent('__commit')}" onmouseup="newEvent()"/>

 <script type="text/javascript">

   function newEvent(){
        alert("your code");

share|improve this answer
I'd love to have happy news about your final answer, but the sad part is that the onmouseup button event seems to work when IT wants to... what I need is to capture the onclick event using jQuery and inside the jquery function do: 1. submit the form data 2. redirect or do whatever the problem, however, is that the ddwrt:gen** code is not useful inside a js function or refuses to cooperate with the script at all.... – user18136 Jul 9 '13 at 20:27

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.