Reputation: 9621
I have a drop down list and some styles applied to it from two js files, included in head like:
<script type="text/javascript" src="js/functions.js"></script>
<script type="text/javascript" src="js/jquery.jqtransform.js"></script>
All it's working great when the page is loading for the first time.
But when i do an ajax request on this page the styles applied before, are lost, so i have included the js src files from the code behing like:
protected void Page_PreRender(object sender, EventArgs e)
{
loadJs();
}
private void loadJs()
{
ScriptManager.RegisterClientScriptInclude(this,
typeof(Page),
"AlertScript",
ResolveClientUrl("~/Site/js/jquery.jqtransform.js"));
ScriptManager.RegisterClientScriptInclude(this,
typeof(Page),
"AlertScript2",
ResolveClientUrl("~/Site/js/functions.js"));
}
But...it's still not working although i see in the broswer - view source that the js files are loaded correctly in the body...
Do you have any suggestion?
Thanks in advance.
Upvotes: 1
Views: 886
Reputation: 39695
In your ajax return function (on the html page) you need to reapply the jquery commands you run the first time the page loads.
jQuery runs over the DOM and does what you tell it to. When the ajax call returns and replaces a part of the page, all runtime changes for that region are lost, so you need to reapply them.
Basically you need to call whatever function is called in jqtransform.js and in functions.js on page load on the html element which is replaces.
Upvotes: 1