Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
JQgrid and Jquery UI Modal Confirmation
25/11/2010
17:50
Avatar
rmvenancio
Portugal
Member
Members
Forum Posts: 12
Member Since:
09/11/2010
sp_UserOfflineSmall Offline

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 ? ", ""];
                }

25/11/2010
22:57
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

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 

26/11/2010
15:28
Avatar
rmvenancio
Portugal
Member
Members
Forum Posts: 12
Member Since:
09/11/2010
sp_UserOfflineSmall Offline

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

Forum Timezone: Europe/Sofia

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.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information