Save button triggered without being clicked.

3 posts, 0 answers
  1. Rick
    Rick avatar
    21 posts
    Member since:
    Jul 2015

    Posted 24 Oct 2015 Link to this post

    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. Patrick
    Admin
    Patrick avatar
    174 posts

    Posted 26 Oct 2015 Link to this post

    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!
     
  3. Kendo UI is VS 2017 Ready
  4. Rick
    Rick avatar
    21 posts
    Member since:
    Jul 2015

    Posted 26 Oct 2015 in reply to Rick Link to this post

    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

Back to Top