如何动态刷新jquery-ui?

时间:2013-11-30 15:36:22

标签: javascript jquery jquery-ui bookmarklet

我在书签中使用jquery,jquery-ui和其他库。 只有自定义进程驻留在书签中。 jquery-ui是从外部脚本加载的,我在我的网络存储上制作了一份副本(仅出于兼容性原因)。 为此,我使用了一段代码:

function $L(c,f){
    if(window.jQuery)
    {/* mark all previous occurences of this script then remove it*/
        var l=$("script[src^=\""+c+"\"]");
        if(l.length>0)
        {
            var n=l.length;
            for(j=0;j<n;j++)
                l[j].setAttribute("class","__remove");
            $(".__remove").remove();
        }
    }

    var s=document.createElement("script");
    s.addEventListener("load",function(){
        f();
    });
    s.setAttribute("src",c+"?"+timestamp);
    /*document.getElementsByTagName("head")[0].appendChild(s);*/
    var h=document.getElementsByTagName("head")[0];
    h.insertBefore(s,h.firstChild);
};

然后:

$L(jquery_ui,function(){
    /* do stuff */
});

我想做的是当用户点击bookmarlet时,bookmarklet总是在我的存储库中使用最新版本的jquery-ui。不仅在刷新页面时,还是在网站上的其他页面上。

服务器上的jquery-ui脚本文件应该因任何原因而改变(应用程序升级) 一切顺利,点击书签时,脚本会重新加载。 当我修改服务器上的jquery-ui文件,然后单击bookmarklet时,版本更改。但经过第二次更改后,我被卡住了,没有版本更改。

所以我猜变量$ ui存在问题。 我该怎么做才能避免这种情况?

0 个答案:

没有答案