解決jQuery插件tipswindown與hintbox沖突
更新時間:2010年11月05日 22:16:55 作者:
先掃下盲:tipswindown是jQuery的彈窗插件,可以使用url或當前頁元素顯示在模擬層中;hintbox是jQuery的類似Google Suggestions插件。
使用情形如下:
頁面a.aspx中點擊按鈕彈出模擬層,在這個層中有一個輸入文本框“監(jiān)督人”處調(diào)用hintbox來產(chǎn)生即時查詢功能。
$("#windown-content").ajaxStart(function(){
$(this).html("<img src='"+templateSrc+"/images/loading.gif' class='loading' />");
});
將其改為:
$("#windown-content").html("<img src='"+templateSrc+"/images/loading.gif' class='loading' />");
原因是兩個插件即使是在不同情形下觸發(fā)ajax事件,使用的仍是同一對象,即jQuery.js中出現(xiàn)的
ajaxSetup: function( settings ) {
jQuery.extend( jQuery.ajaxSettings, settings );
},
ajaxSettings: {
url: location.href,
global: true,
type: "GET",
contentType: "application/x-www-form-urlencoded",
processData: true,
async: true,
/*
timeout: 0,
data: null,
username: null,
password: null,
*/
// Create the request object; Microsoft failed to properly
// implement the XMLHttpRequest in IE7, so we use the ActiveXObject when it is available
// This function can be overriden by calling jQuery.ajaxSetup
xhr:function(){
return window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
},
accepts: {
xml: "application/xml, text/xml",
html: "text/html",
script: "text/javascript, application/javascript",
json: "application/json, text/javascript",
text: "text/plain",
_default: "*/*"
}
},
這樣在當前窗體中就會是只有一個xhr對象存在,因為在hintbox中的ajax事件會觸發(fā)tipswindown的ajaxStart事件。
可下載修改過后的tipswindown,點擊下載。
頁面a.aspx中點擊按鈕彈出模擬層,在這個層中有一個輸入文本框“監(jiān)督人”處調(diào)用hintbox來產(chǎn)生即時查詢功能。
直接調(diào)用產(chǎn)生了如下情形:
于是找到jquery.hintbox-1.3.js這個文件,發(fā)現(xiàn)其中出現(xiàn)這么一行:
復制代碼 代碼如下:
$("#windown-content").ajaxStart(function(){
$(this).html("<img src='"+templateSrc+"/images/loading.gif' class='loading' />");
});
將其改為:
復制代碼 代碼如下:
$("#windown-content").html("<img src='"+templateSrc+"/images/loading.gif' class='loading' />");
原因是兩個插件即使是在不同情形下觸發(fā)ajax事件,使用的仍是同一對象,即jQuery.js中出現(xiàn)的
復制代碼 代碼如下:
ajaxSetup: function( settings ) {
jQuery.extend( jQuery.ajaxSettings, settings );
},
ajaxSettings: {
url: location.href,
global: true,
type: "GET",
contentType: "application/x-www-form-urlencoded",
processData: true,
async: true,
/*
timeout: 0,
data: null,
username: null,
password: null,
*/
// Create the request object; Microsoft failed to properly
// implement the XMLHttpRequest in IE7, so we use the ActiveXObject when it is available
// This function can be overriden by calling jQuery.ajaxSetup
xhr:function(){
return window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
},
accepts: {
xml: "application/xml, text/xml",
html: "text/html",
script: "text/javascript, application/javascript",
json: "application/json, text/javascript",
text: "text/plain",
_default: "*/*"
}
},
這樣在當前窗體中就會是只有一個xhr對象存在,因為在hintbox中的ajax事件會觸發(fā)tipswindown的ajaxStart事件。
可下載修改過后的tipswindown,點擊下載。
您可能感興趣的文章:
相關文章
基于jquery實現(xiàn)的文字向上跑動類似跑馬燈的效果
這篇文章主要介紹了基于jquery實現(xiàn)的文字向上跑動效果類似跑馬燈,需要的朋友可以參考下2014-06-06利用jquery實現(xiàn)驗證輸入的是否是數(shù)字、小數(shù),包含保留幾位小數(shù)
本文主要介紹了利用jquery實現(xiàn)驗證輸入的是否是數(shù)字、小數(shù),包含保留幾位小數(shù),代碼清晰,容易理解。有需要的朋友可以參考下2016-12-12jQuery實現(xiàn)花式輪播之圣誕節(jié)禮物傳送效果
這篇文章主要介紹了jQuery實現(xiàn)花式輪播之圣誕節(jié)禮物傳送效果,需要的朋友可以參考下2016-12-12jQuery旋轉(zhuǎn)插件—rotate支持(ie/Firefox/SafariOpera/Chrome)
網(wǎng)上發(fā)現(xiàn)一個很有意思的jQuery旋轉(zhuǎn)插件,支持Internet Explorer 6.0+ 、Firefox 2.0 、Safari 3 、Opera 9 、Google Chrome,高級瀏覽器下使用Transform,低版本ie使用VML實現(xiàn),感興趣的朋友可以了解下2013-01-01