javascript - 两个脚本之间的jquery冲突

标签 javascript jquery conflict

我在使用的 2 个 jqueries 之间有冲突问题,我已经检查了 jQuery.noConflict() 东西但是因为我是一个新手所以我不知道如何处理它,所以如果你能帮助我,那就太好了。

似乎“jquery-2.1.4.min.js”让“jquery-ui-1.8rc1.custom.min.js”停止工作,所以没有收到弹出窗口,没有任何反应。

提前致谢。

代码:

<script src="/myjs/js/jquery-ui-1.8rc1.custom.min.js" type="text/javascript"></script>
<script type="text/javascript">


    $(document).ready(function () {

        var mensaje = "<%= mensaje%>";
        var $dialogDel = $('<div></div>')
        .html(mensaje)
        .dialog({
            autoOpen: false,
            title: 'Alert',
            buttons: { "Ok": function() { $(this).dialog("close"); } }  
        });
        if(mensaje != ""){
            $dialogDel.dialog('open');
        }
    }); 

    function add(){

        var archivo = document.adddoc.add_archivo.value;

        extensiones_permitidas = new Array(".htm", ".html", ".txt", ".doc",".xls",".zip",".pdf",".jpg",".rar",".docx",".xlsx"); 


        extension = (archivo.substring(archivo.lastIndexOf("."))).toLowerCase(); 

        permitida = false; 
        for (var i = 0; i < extensiones_permitidas.length; i++) { 
           if (extensiones_permitidas[i] == extension) { 
           permitida = true; 
           break; 
           } 
        } 
        if (!permitida) { 
            alert("The extension is not correct");
        }else{
            var $dialog = $('<div></div>')
            .html('Doc beeing uploaded, please wait.')
            .dialog({
                autoOpen: false,
                title: 'Alert'
            });
            $dialog.dialog('open');
            $('#adddoc').submit();
        }

    }

</script>

    <script  type="text/javascript" src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
    <script src="/myjs/js/jquery.ezdz.min.js"></script>
   <script>

        $('[type="file"]').ezdz({
            text: 'drop a file',
            validators: {
                maxWidth:  100,
                maxHeight: 200
            }/* ,
            reject: function(file, errors) {
                if (errors.mimeType) {
                    alert(file.name + ' must be an image.');
                }

                if (errors.maxWidth) {
                    alert(file.name + ' must be width:600px max.');
                }

                if (errors.maxHeight) {
                    alert(file.name + ' must be height:400px max.');
                }
            } */
        });
    </script> 

最佳答案

jquery-ui-1.8rc1 is shipped with jquery-1.4.1.js .

由于您使用的是更新版本的 jQuery,因此可能存在兼容性问题。

您是否可能在控制台中收到任何警告或错误?也许与deprecated functions有关.

关于javascript - 两个脚本之间的jquery冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30662615/

相关文章:

jquery - 显示/隐藏 div jquery 不能在固定位置工作

database - "conflict serializable"和 "conflict equivalent"有什么区别?

javascript - 尝试使用触摸事件获得 CSS3 聚光灯效果

javascript - 我如何找到我在 HTML5 Canvas 中单击的网格正方形元素

javascript - 取消 JavaScript promise

jQuery 无法在 AJAX 函数内定义变量

python - 我可以在同一台计算机上运行两个 Web 服务器吗?

jquery - 如何让 Iscroll 和 Lazy Load jQuery 插件一起工作?

javascript - 计算不为空的 props

javascript - 如何在 Redis 中进行持久化存储?