zoukankan      html  css  js  c++  java
  • 解决jQuery插件tipswindown与hintbox冲突

    先扫下盲:tipswindown是jQuery的弹窗插件,可以使用url或当前页元素显示在模拟层中;hintbox是jQuery的类似Google Suggestions插件。

    使用情形如下:

    页面a.aspx中点击按钮弹出模拟层,在这个层中有一个输入文本框“监督人”处调用hintbox来产生即时查询功能。

    直接调用产生了如下情形:

    于是找到jquery.hintbox-1.3.js这个文件,发现其中出现这么一行:

    $("#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' />");

    原因是两个插件即使是在不同情形下触发ajax事件,使用的仍是同一对象,即jQuery.js中出现的

    代码
    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事件会触发tipswindown的ajaxStart事件。

    可下载修改过后的tipswindown,点击下载

  • 相关阅读:
    编写Music类
    Double-checked locking and the Singleton pattern--双重检查加锁失效原因剖析
    C语言中,数组名作为参数传递给函数时,退化为指针
    蘑菇街笔试
    动态规划--股市买入卖出时间点选择问题
    Java 查看死锁的方法
    linux中shell变量$#,$@,$0,$1,$2的含义解释
    Spring中bean的配置
    为什么要使用连接池
    Hadoop Bloom filter应用示例
  • 原文地址:https://www.cnblogs.com/walkingp/p/1867934.html
Copyright © 2011-2022 走看看