Forum
13:05
25/10/2008
Maybe i'm wrong, but i'm experiencing inconsistent afterSubmit behaviour using
[jqgrid code].navGrid(
"#pagerid",{add:true,edit:true,del:true,search:false,refresh:false},
{
reloadAfterSubmit:true,
closeAfterEdit:true,
beforeShowForm:function(){alert("beforeShowForm edit");},
afterSubmit:function(r,data){alert('afterSubmit edit');}
}
,
{
reloadAfterSubmit:true,
closeAfterAdd:true,
beforeShowForm:function(){alert("beforeShowForm new");},
afterSubmit:function(r,data){alert('afterSubmit new');}
}
);
When i click on the edit button i get as expected
1) alert("beforeShowForm edit");
2) alert('afterSubmit edit');
but when i click on the new button i get
1) alert("beforeShowForm new");
2) alert('afterSubmit edit'); <- i expected an alert('afterSubmit new');
trying the opposite (first hit the new button, than the edit button) you can experience the opposite, this time
1) alert("beforeShowForm new");
2) alert('afterSubmit new');
but when i click on the new button i get
1) alert("beforeShowForm edit");
2) alert('afterSubmit new');
... so to make a long story short, it seems that the once the afterSubmit event is initialized with a function you can't change it ...
Maybe someone of you crashed on this problem before ...
I'm trying it on IE7, windows XP, latest jqgrid release (3.3).
Hope i'm wrong and this is not a bug ...
Cheers
CJ
02:10
Moderators
30/10/2007
Hello,
Thank you. Definitley I will check this.
Regards
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
18:00
25/10/2008
Ok after some research i found what could be the reason of this issue:
the reason is how editGridRow is implemented :
editGridRow : function(rowid, p){
p = $.extend({
// blah blah blah
}, $.jgrid.edit, p || {});
return this.each(function(){
// various references to p
$.ajax( // blah blah,
complete:function(a,b){
// again references to p
if ( typeof p.afterSubmit === 'function' )
p.afterSubmit(a,b);
}
}
to be short : you can't reference p safely inside this.each and inside complete because it's an out of scope variable, instead if you do something like this (which is pretty raw i know, but it works) ...
var CJ_customglobalvar = null;
editGridRow : function(rowid, p){
p = $.extend({
// blah blah blah
}, $.jgrid.edit, p || {});
CJ_customglobalvar = p;
return this.each(function(){
// various references to p -> become references to CJ_customglobalvar
$.ajax( // blah blah,
complete:function(a,b){
// again references to p becomes references to CJ_customglobalvar
if ( typeof CJ_customglobalvar.afterSubmit === 'function' )
CJ_customglobalvar.afterSubmit(a,b);
}
}
.... so i hope to have suggested you some kind of solution ... for me it worked out ...
Cheers
CJ
01:26
Moderators
30/10/2007
Hello,
Thank you very much for this. It is true.
We should have working solutions 🙂 and I will implement your
correction.
Best Regards
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
03:47
i think to have a similar error.
afterSubmit event seems to happen before server calling and i can't receive response data and i've verified that
jQuery(gridName).editGridRow('new',{height:150,reloadAfterSubmit:true,editData:{action:'new',afterSubmit:function(response,postdata){alert(response)}}});
return always undefined even if server call is completed and database updated.
Paolo.
12:53
Moderators
30/10/2007
Hello,
1. maybe this will work afterSubmit:function(response,postdata){alert(response.responseText); return [true,"",""];}}
2. this event should return array with special values - see docs
Regards
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
Most Users Ever Online: 715
Currently Online:
73 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66