This is a migrated thread and some comments may be shown as answers.

Save button triggered without being clicked.

2 Answers 75 Views
Window
This is a migrated thread and some comments may be shown as answers.
Rick
Top achievements
Rank 2
Rick asked on 24 Oct 2015, 09:56 PM

The attached HTML has a problem. When I use a popup window and cancel the closing of a window with field changes, the Save button is triggered even though it has not yet been clicked. Below is the trace in the console log displays. Note that the bottom lines indicate the Save button has been triggered and the changes saved to the datasource. Yet, it has not been clicked.

pid: 2
row: Object { _events={...},  _handlers={...},  ProductID=2,  more...}
set: e.field = current
current: Object { _events={...},  _handlers={...},  ProductID=2,  more...}
set: e.field = current.UnitPrice
set: fName = UnitPrice
set: hasChanges = true
close: e.userTriggered = true
close: hasChanges is true
click: #CancelButton
click: Save
changes: UnitPrice changed from 21 to 20,
close: e.userTriggered = true
close: hasChanges is true

My expectation was that if I called e.preventDefault that the window close would be stopped and that would be that. For some reason the Save button is involved. Using the confirm code works fine. But I would like better control and it looks less refined than a popup window that can have more messages and maybe even links to help.

Weird. And, it's not even Halloween yet. That's next week.

Rick

2 Answers, 1 is accepted

Sort by
0
Patrick | Technical Support Engineer, Senior
Telerik team
answered on 26 Oct 2015, 03:32 PM
Hi Rick,

Take a look at the updated demo I created based on your sample.  

After looking over the code, I believe this is your issue:
$("button").click(function() { console.error("click: Save");

What you want in this line is:
$("#save").click(function() { console.error("click: Save");

Hopefully, this helps clear things.

Regards,
Pat
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Rick
Top achievements
Rank 2
answered on 26 Oct 2015, 08:31 PM

Yes. I found the problem also. Did not think ​anyone would stay so late. The attached code has this fix and a whole lot more. It catches the window close with pending changes. And, it has a working UNDO button that also restores the UI values. This is not my final version which I intend to be a function call.

Thanks for your help.

Rick

Tags
Window
Asked by
Rick
Top achievements
Rank 2
Answers by
Patrick | Technical Support Engineer, Senior
Telerik team
Rick
Top achievements
Rank 2
Share this question
or