Issue with jQuery 'afterComplete' event

QuestionsIssue with jQuery 'afterComplete' event
Jonathan Lawson asked 6 years ago

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.
 Dev Environment Console
In our production environment the Ajax response come after the function is called, and therefore fails to run.
Production Environment Console
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?

2 Answers
Abu Ghufran Staff answered 6 years ago

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]
}

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Abu Ghufran Staff answered 6 years ago

You can try using afterSubmit like this:

$g["edit_options"]["afterSubmit"] = 'function(response) { if(response.status == 200)
{
return [true,""];
}
}';
_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Your Answer

17 + 1 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?