Grid popup editor's close event fired twice

4 posts, 1 answers
  1. Casimodo
    Casimodo avatar
    71 posts
    Member since:
    Mar 2015

    Posted 08 Mar 2016 Link to this post

    Hi,

    the grid popup editor window's close event is fired twice when closing the popup window via the close button (not the cancel or save button).

    See this dojo: http://dojo.telerik.com/IdIYe

    Even using the "one" binding produces a duplicate event:

    edit: function (e) {
        e.container.data("kendoWindow").one("close", onEditorClosed);
    }

    I depend on this event being fired only once, because I'm trying to fix my previous issue with flashing nested modal windows (http://www.telerik.com/forums/avoid-overlay-flash-with-nested-modal-windows).

    I tried to debug the code: _close() of window is called twice, once via _windowActionHandler() and once via _destroyEditable() -> close(). The strange thing is that both code paths seem to operate on different _events objects. The first code path calls and removes the "one" event handler from _events, but on the second path, _events appears to be unchanged, i.e. the "one" event handler is still there and called again.

    Any clues? Looks like a bug to me.

    Regards

    Kasimier Buchcik

  2. Answer
    Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    2466 posts

    Posted 09 Mar 2016 Link to this post

    Hi Casimodo,

    You have correctly pinpointed the root of the problem, where the close method of the Window is called manually within the _destroyEditable function, even if the close button was clicked. You have two options for handling this limitation:
    • Handle the "deactivate" event of the Window, instead of the "close" event: 
    edit: function (e) {
      e.container.data("kendoWindow").one("deactivate", onEditorClosed);
    },

    • Use the "save" and "cancel" events of the Grid:
    cancel: function(e){
      onEditorClosed();
    },
    save: function(e){
      onEditorClosed();
    }

    Hope this helps.


    Regards, Konstantin Dikov
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. Casimodo
    Casimodo avatar
    71 posts
    Member since:
    Mar 2015

    Posted 10 Mar 2016 in reply to Konstantin Dikov Link to this post

    Hi Konstantin,

    I'm not sure if the main worrying issue really came through.

    The call to close() via _destroyEditable() is only responsible for triggering the duplicate "close" event twice. This could be normally be worked-around by using the "one" event binding.

    Please try to debug this scenario using a "one" event binding. The _events object (or maybe even an ancestor object of it) appears to be duplicate. Both code paths effectively operate on a different set of event bindings. Why does the already removed "one" event binding reappear in _events when close() is called via _destroyEditable()? I think, this should worry us more than the duplicate call to close().

    I am now binding to the "deactivate" event as you suggested. Works fine.

    Regards & thanks

    Kasimier Buchcik

  4. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    2466 posts

    Posted 14 Mar 2016 Link to this post

    Hello Kasimier,

    I am glad to see that everything works correctly with the suggested approaches.

    As for the duplicate "close" event, I will forward this to our developers team for further investigation. 


    Best Regards,
    Konstantin Dikov
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
Back to Top