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

Override the close() method of a modalView

4 Answers 191 Views
ModalView
This is a migrated thread and some comments may be shown as answers.
Relez
Top achievements
Rank 1
Relez asked on 18 Feb 2013, 03:08 PM
Hello everyone, I would like to override the close() function of a modalView. What I need is to do something first before it closes.

Here is what I am trying to do:

var modalView = $("#modalview-menu").data("kendoMobileModalView");    
modalView.close = function () {
  // do something...
  ...
  // then close it.
}

Thanks!

4 Answers, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 20 Feb 2013, 12:48 PM
Hi Relvis,

In the next major release, which is scheduled for end of March, we plan to introduce init, open and close events for the Modal View widget.

Meanwhile you can use the following approach:
var modalview = $("#modalview-login").data("kendoMobileModalView");
var closeOrigin = modalview.close;
modalview.close = function() {
    //do stuff
    closeOrigin.call(m);
}

Please note that depending on the implementation, changing the widgets' API may lead to unexpected side effects which is why we do not support such custom solutions.

Regards,
Alexander Valchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Anton
Top achievements
Rank 1
answered on 28 Feb 2013, 05:43 AM
Hi Alexander -

In your sample code, what is the 'm' in closeOrigin.call(m)?
I tried doing this for the show() method of kendoMobileLoader but I'm getting an error when I call the original show().

0
Alexander Valchev
Telerik team
answered on 28 Feb 2013, 09:27 AM
Hello Anton,


Please accept my apology for the inconvenience caused.
The 'm' is the modalview. The correct code is:
var modalview = $("#modalview-login").data("kendoMobileModalView");
var closeOrigin = modalview.close;
modalview.close = function() {
    //do stuff
    closeOrigin.call(modalview);
}


Regards,
Alexander Valchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Anton
Top achievements
Rank 1
answered on 01 Mar 2013, 07:19 AM
Thanks Alexander! No inconvenience caused at all. I wonder why I hadn't thought of using 'modalview' in place of the 'm'.
Anyway, it's all working now! Thanks a bunch!
Tags
ModalView
Asked by
Relez
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Anton
Top achievements
Rank 1
Share this question
or