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

[Solved] ClientEvents problem with LoadContentFrom

1 Answer 47 Views
Window
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Pablo Martinez
Top achievements
Rank 1
Pablo Martinez asked on 13 Jun 2012, 04:14 AM
I have a page with this Window

@{ Html.Telerik().Window()
       .Name("WindowGoogle")
       .Draggable(true).HtmlAttributes(new Dictionary<string, object>() { { "class", "new_modal" } })
       .Modal(true).Buttons(b => b.Close())
       .Title(" ").LoadContentFrom("Index", "Google")
       .ClientEvents(events =>events.OnActivate("onActivate").OnClose("onClose"))   
.Width(702)
.Height(500)
.Visible(false)
.Render();}


When web site runs I get a this errors

onClose is not defined
...onClose:onClose, onActivate:onActivate, modal:true, contentUrl:'/Google/Index', ...

onActivate is not defined
...onClose:onClose, onActivate:onActivate, modal:true, contentUrl:'/Google/Index', ...


When I removed the .ClientEvents(events =>events.OnActivate("onActivate").OnClose("onClose"))   from Html.Telerik().Window(), the web site runs  with out errors

if I change it with this also works

@{ Html.Telerik().Window()
       .Name("WindowGoogle")
       .Draggable(true).HtmlAttributes(new Dictionary<string, object>() { { "class", "new_modal" } })
       .Modal(true).Buttons(b => b.Close())
       .Title(" ").Content(@<text>@Html.Partial(MVC.Google.Views.)</text>)
       .ClientEvents(events =>events.OnActivate("onActivate").OnClose("onClose"))   
.Width(702)
.Height(500)
.Visible(false)
.Render();}


I want to know what  is the problem using the ClientEvents when I used LoadContentFrom,
Any help please.

Thanks

1 Answer, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 13 Jun 2012, 10:58 AM
Hello Pablo,

Basically it depends where you have declared your client event functions - they need to be available when the window is initialized on the client. If you have declared them inside the partial view and you are loading it with Ajax they wont be available and such error will be thrown. If this is the case declare the functions in View you declared the window so they are declared before the window is initialized.
If this is not the case please provide more information about the current setup.

Greetings,
Petur Subev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now.
Tags
Window
Asked by
Pablo Martinez
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Share this question
or