Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Telerik MVC Extensions (superseded) > General Discussions > Telerik scripts inside partial view

Not answered Telerik scripts inside partial view

Feed from this thread
  • Villi avatar

    Posted on Mar 26, 2012 (permalink)

    I have a few partial views which i load through ajax and each of them got diffrent scripts like : onLoad, onContentLoad and etc..
    now after i load the first partial view everything work ok and all the scripts work correctly but after i try to load another partial view it seems it wont read scripts which are in the same page of the partial view instead it reads the functions from the last partial view which btw are deleted by jquery before i load the next partial view.

    It seems the the scripts are saved in cache or somewhere else I cant find the correct way to load the scripts in every partial view to read them as its own.

    Im using mvc 3 with razor.

    Thanks,
    Villi Katrih.

    Reply

  • Dadv Master avatar

    Posted on Mar 27, 2012 (permalink)

    Hi,

    Try to add to your controller : 
    [OutputCache(Duration = 0, NoStore = true)]

    Don't forget to clear all your browsers cache before test that.

    Reply

  • Villi avatar

    Posted on Mar 27, 2012 (permalink)

    Its not working it seem the the scripts not rendered into the partial view its very strange...

    Reply

  • Dadv Master avatar

    Posted on Mar 28, 2012 (permalink)

    Not render? do you see the script in the source after render? if yes where did you place it  on top or at end?

    Your problem could be a lot of thing, can you provide some sample?

    Reply

  • Villi avatar

    Posted on Mar 28, 2012 (permalink)

    Partial view 1: 

    @model blablabla
     
    <script type="text/javascript">
    function onLoad1(e)
    {
       alert('onload1');
    }
    </script>
    @(Html.Telerik().TabStrip()
               .Name("TabStrip")
               .ClientEvents(events =>
               {
                    events.OnLoad("onLoad1");
               })
               .BindTo(Model,
                       (item, tabData) =>
                       {
                           CODE...
                       }).SelectedIndex(ViewBag.SelectedTab))

    partial view 2:

    @model blablabla
     
    <script type="text/javascript">
    function onLoad2(e)
    {
       alert('onload2');
    }
    </script>
    @(Html.Telerik().TabStrip()
               .Name("TabStrip")
               .ClientEvents(events =>
               {
                    events.OnLoad("onLoad2");
               })
               .BindTo(Model,
                       (item, tabData) =>
                       {
                           CODE...
                       }).SelectedIndex(ViewBag.SelectedTab))

    now before i call the second partial view i do $('#container').html(''); on the partial view 1 container so it clears everything and then
    through ajax request i get the second partial view it seems everything is ok untill i try to call the first partial view again.
    The layout is never refreshed no postbacks are commited its very strange looks like scripts arent loaded the second time or it remembers the last partial view and uses its own scripts and thats why the next partial view cant find its own function names thats what i think..

    Reply

  • Dadv Master avatar

    Posted on Mar 28, 2012 (permalink)

    Try to change the tab name :TabStrip 

    the events.OnLoad is link to the id (name) of the tabstrip, you should have some behavior
    if you load different items with the same id.

    Scripts loaded are not unloaded by the browser if nobody tell it to unload it (.html('') only remove the tags not the load script).


    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Telerik MVC Extensions (superseded) > General Discussions > Telerik scripts inside partial view