Tell me more ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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

1 Answer

up vote 2 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

Your Answer

 
discard

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.