This question is locked. New answers and comments are not allowed.
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.
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.
5 Answers, 1 is accepted
0
Dadv
Top achievements
Rank 1
answered on 27 Mar 2012, 01:58 PM
Hi,
Try to add to your controller :
[OutputCache(Duration = 0, NoStore = true)]
Don't forget to clear all your browsers cache before test that.
Try to add to your controller :
[OutputCache(Duration = 0, NoStore = true)]
Don't forget to clear all your browsers cache before test that.
0
Villi
Top achievements
Rank 1
answered on 27 Mar 2012, 03:48 PM
Its not working it seem the the scripts not rendered into the partial view its very strange...
0
Dadv
Top achievements
Rank 1
answered on 28 Mar 2012, 08:44 AM
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?
Your problem could be a lot of thing, can you provide some sample?
0
Villi
Top achievements
Rank 1
answered on 28 Mar 2012, 10:59 AM
Partial view 1:
partial view 2:
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..
@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..
0
Dadv
Top achievements
Rank 1
answered on 28 Mar 2012, 11:32 AM
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).
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).