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

Using Namespaced functions with events

2 Answers 66 Views
Window
This is a migrated thread and some comments may be shown as answers.
Kim
Top achievements
Rank 1
Kim asked on 22 Apr 2013, 05:42 PM
This is my first time using kendo window and I have run into a problem.
I want to use a namespaced function for the OnClose event as below.

@(Html.Kendo().Window()
    .Name("CreateProduct")
    .Title("Create Product")
    .Width(600)
    .Modal(true)
    .Events(ev => ev.Close("OnClose"))
    .Visible(false)
    .Content(@Html.Partial("CreationForm").ToString())
)

Right now you can see that I am just using the OnClose function, but I wanted to be able to write something like:

<script>
var CurrentPageNamespace = {};
CurrentPageNamespace.OnClose = function(){
    //Do Some Work Here
}
</script>

And then add it to the Window's on close:
@(Html.Kendo().Window()
    .Name("CreateProduct")
    .Title("Create Product")
    .Width(600)
    .Modal(true)
    .Events(ev => ev.Close("CurrentPageNamespace.OnClose"))
    .Visible(false)
    .Content(@Html.Partial("CreationForm").ToString())
)

I tested this with a simple alert, and if I removed the namespace from OnClose it would work, and with the namespace included nothing would happen.  Is it possible to use a namespace with Kendo UI Window events?

Thanks in advance.

2 Answers, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 24 Apr 2013, 12:14 PM
Hello Kim,

Your code looks completely valid. I tried it on my side and everything seems to be working as expected:

<script>
    var CurrentPageNamespace = {};
    CurrentPageNamespace.OnClose = function () {
        alert(1)
    }
</script>
 
@(Html.Kendo().Window()
    .Name("CreateProduct")
    .Title("Create Product")
    .Width(600)
    .Modal(true)
    .Events(ev => ev.Close("CurrentPageNamespace.OnClose"))
    .Visible(true)
    .Content("Some Content")
)

I suggest you to put this into a demo project so we can see what could go wrong. Probably there are other JavaScript errors?

Kind Regards,
Petur Subev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Kim
Top achievements
Rank 1
answered on 28 Apr 2013, 02:06 AM
You are correct. I just refactored a bunch of my javascript and it seems to be working as intended now. I must have had an error somewhere else (although my log wasn't showing anything). Anyway, thanks for the reply, it caused me to go back and try again and see that it is all working as intended.
Tags
Window
Asked by
Kim
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Kim
Top achievements
Rank 1
Share this question
or