Hello Abu,
My team and I love your software and have been using it for years! A recent issue has left us stumped, we use the jQuery ‘afterComplete’ event which you expose through:
$opts[‘edit_options’][“afterComplete”] = “function (form) { return someFunction(form); }”;
In our dev environment this function is called after the Ajax response is received and the function runs as expected.
In our production environment the Ajax response come after the function is called, and therefore fails to run.
The code is identical on both environments, but the setups are different. We run XAMPP to test locally and in production we are using a cloud provider.
We think that it may be a race condition because in your distribution file jqgrid_dist.php there is no callback for the after complete event for edit_options. We see on ‘$this->options[“add_options”][“afterComplete”]’ you do wait for a response. Could this be the issue?
Hello Jon,
Please see if this documentation help.
afterComplete
This event fires immediately after all actions and events are completed and the row is inserted or updated in the grid.
afterComplete : function (response, postdata, formid) {…}
where
response is the data returned from the server (if any)
postdata an array, is the data sent to the server
formid is the jQuery object of form id, you can use formid[0].id to get form id.
afterSubmit
fires after response has been received from server. Typically used to display status from server (e.g., the data is successfully saved or the save cancelled for server-side editing reasons). Receives as parameters the data returned from the request and an array of the posted values of type id=value1,value2.
When used this event should return array with the following items [success, message, new_id]
where
success is a boolean value if true the process continues, if false a error message appear and all other processing is stopped. (message is ignored if success is true).
new_id can be used to set the new row id in the grid when we are in add mode.
afterSubmit : function(response, postdata)
{
…
return [success,message,new_id]
}
You can try using afterSubmit like this:
$g["edit_options"]["afterSubmit"] = 'function(response) { if(response.status == 200)
{
return [true,""];
}
}';