开发者

include jQuery source file in asp.net

I have a drop down list and some styles applied to it from two js files, included in head like:

开发者_如何学Go <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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜