2015-06-05 97 views
4

我有使用2个jqueries之间的冲突问题,我已经检查了jQuery.noConflict()thingy但是因为我有点新手入它,我不知道该怎么去用它做,所以如果你能给我一只很棒的手。两个脚本之间的jquery冲突

看来,“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> 
+2

你有没有尝试在jQuery UI之前包括jQuery? –

+0

你可以制作一个JSFiddle吗?我们会看到,如果只有你有这个问题。 – Seblor

+1

@ user3272243好的。你有没有考虑使用jQuery UI的更新版本,因为你使用最新的(我认为?)版本的jQuery本身 –

回答

3

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

由于您使用的是较新版本的jQuery,因此可能会出现兼容性问题。

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

+0

是的,当我点击应该打开弹出窗口的按钮时:TypeError:$(...).html(...)。dialog不是一个函数 –

+0

你使用了jquery-ui-1.8rc1.custom.min.js。我认为这是一个只选择了一些功能的版本。对话框可能不包括在内。 – Hermien