2012-08-14 62 views
12

我使用JQuery UI 1.8.10和jQuery最新版本。JQuery UI 1.8.10無法讀取未定義的屬性'3'

我的代碼是:

<script src="http://code.jquery.com/jquery-latest.js"></script> 
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.10/jquery-ui.js"></script> 
<script type="text/javascript" src="/cms/ww.admin/login/login.js"></script> 
</head> 
<body> 

<div id="header"></div> 
<?php 
    if(isset($_REQUEST['login_msg'])) 
    { 
     require SCRIPTBASE.'cms/ww.incs/login-codes.php'; 
     $login_msg = $_REQUEST['login_msg']; 
     if(isset($login_msg_codes[$login_msg])) 
     { 
      echo '<script>$(function(){$("<strong>'.htmlspecialchars($login_msg_codes[$login_msg]).'</strong>").dialog({modal:true});});</script>'; 
     } 

?> 

爲什麼這給出一個無法讀取未定義的錯誤的特性 '3'?

,使該錯誤是jquery-ui.js on line 186

好吧,現在我把它改成了文件:

</head> 
<body> 

<div id="header"></div> 
<div id="login-msg"></div> 
<?php 
if(isset($_REQUEST['login_msg'])){ 
require SCRIPTBASE.'cms/ww.incs/login-codes.php'; 
$login_msg=$_REQUEST['login_msg']; 
if(isset($login_msg_codes[$login_msg])){ 
    echo '<script>$(function(){ 
        $("#login-msg").html("<strong>'.htmlspecialchars($login_msg_codes[$login_msg]).'</strong>").dialog({modal:true});});</script>'; 
} 
} 
?> 

但還是同樣的錯誤

+0

你確定你不需要/前' 'CMS/ww.incs /登錄-codes.php'; – 2012-08-14 08:04:48

+1

什麼行/文件給你這個錯誤? – Jeemusu 2012-08-14 08:06:35

+0

不,我不需要cms之前,因爲thas在de scriptbase。 – 2012-08-14 08:13:54

回答

20

這是一個來自您的jQueryUI的錯誤,它使用了:數據選擇器(如果你在調用堆棧中,你會看到它),這是不贊同/不兼容最新的jQuery。 試着用這個jQueryUI的:

http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.22/jquery-ui.min.js 

例如這裏:

http://jsfiddle.net/techunter/RyUVq/

+2

你可以寫$(「

text

」).dialog(),但它確實不可取,因爲你以後不能對該對話框採取任何行動(沒有選擇器) – 2012-08-14 10:09:23

+0

thx爲了指出 – TecHunter 2012-08-14 10:10:46

+1

謝謝你我的英雄我作爲谷歌搜尋,並試圖找到一個修復阿爾的早晨謝謝你。 – 2012-08-14 10:19:26

0

它可能不是源的問題,但也許爲你的.dialog()小部件設置一個div可以幫助你。

您的js行$("<strong>'.htmlspecialchars($login_msg_codes[$login_msg]).'</strong>").dialog({modal:true}似乎正在使用一個簡單的消息,在大多數情況下它可以正常工作。

你能嘗試使用該行,而不是改變:

$(function() 
{ 
    $("#header") // or any div you have 
    .html("<strong>'.htmlspecialchars($login_msg_codes[$login_msg]).'</strong>") 
    .dialog({modal:true}); 
}); 

還,請確保您的「/cms/ww.admin/login/login.js」是不是錯誤的來源,JS錯誤控制檯很容易丟失,並可以指向你jquery-ui.js而錯誤是在別的地方。

+0

刪除評論,.html需要按照選擇器,如果放在同一行。我在我的答案中添加了一行,login.js文件中包含了什麼內容? – 2012-08-14 09:31:31

+0

我想你忘了a)函數後(應該是函數(),但不是它仍然不工作) – 2012-08-14 09:49:22

+0

更新,謝謝!你有沒有嘗試刪除該行的.dialog()部分?沒有它,你仍然有錯誤?它會排除這部分,你的錯誤肯定來自login.js – 2012-08-14 10:07:17

0

我確認uncompatibility問題。 試圖與 jQuery的1.8.0和jQuery的 的UI-1.8.4

相關問題