Forum
Hello,
I want to have a confirmation window when the user pressed the submit button. Depending on the user choice, the data passed to the server will be different.
The problem is that I get allways the following message before the user confirmation :
"What the F***, Why I reach this code ?"
Anyone have implemented anything similar ?
Thanks.
beforeSubmit: function (postdata, formid) {
if (postdata.cost) {
$(function () {
$("#dialog:ui-dialog").dialog("destroy");
$("#dialog-confirm").dialog({
resizable: true,
height: 200,
width: 300,
closeOnEscape: false,
modal: true,
buttons: {
'Yes': function () {
$(this).dialog("close");
alert("Yes");
return [false, "I pressed Yes", ""];
},
'No': function () {
$(this).dialog("close");
return [false, "I pressed False", ""];
}
}
});
});
}
else return [true, "No problem", ""];
return [false, "What the F***, Why I reach this code ? ", ""];
}
22:57
10/08/2009
Hi rmvenancio,
first of all you code try to return code [false, ...] in all cases, but the main problem is that the $("#dialog-confirm").dialog will work asynchronous. So you program will return always with the return from the one of the last rows of your code.
Instead of the usage of $("#dialog-confirm").dialog I would recommend you to use checkOnSubmit:true or checkOnUpdate:true. Read careful the documentation of the parameters and be sure that you will see the confirmation dialog only if any data is changed in the form.
Best regards
Oleg
Hi OlegK,
Thanks a lot for your help, the code allways return false for debugging porposes.
Unfortenatly the use of checkOnUpdate and CkecOnSubmit not solves my problem. I don't want to look for changes made in the form but only check if a particular field (cost) have values. I have various scenarios (or use cases), but to simplify, imagine the following:
This field (cost) by default, are calculated (no needs user input). But the user have the possibility to input some value in the cost and in this case we don't want the cost value to be replaced with a calculated value without user authorization. In this case, and if the cost field have values, we should ask the user for a boolean choice: Yes or No (replace or not replace with automatic calculations).
I have succeed with an intermitiate solution :
beforeSubmit: function (postdata, formid) {
postdata.replace = true;
if (postdata.cost) { // If Cost
if (!confirm('Replace Cost ? ')) postdata.replace = false; // User don't want the value be replaced
}
return [true, "Replace it", ""]; //In all other cases replace the value
}
This is fine just for now, but is not a perfect solution. The cofirm box is awful and it "hurts" the Look and Feel of my application, the default buttons are a OK and Cancel instead of YES and NO .
When I opened this topic, I tought it was a jqgrid problem. Now, and after you point that the problem occurs essencialy because the dialog works in asynchronous mode I must admit that this is not a jqgrid issue. In any case, my solution works with a jqgrid and I need this behaviour/functionality working in a smooth way. I would like to ask you guys (and girls) possible ways to solve this issue (without using timeouts). Exists any dialogs windows working in synchronous mode ?
Thanks a lot for all your support.
Best regards,
Rui Venâncio
Most Users Ever Online: 715
Currently Online:
58 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