2014-02-07 95 views
0

我的問題是當我運行datepicker.php它自我工作正常 但是當我試圖打開從另一個頁面(測試按鈕)我得到這個錯誤對象[對象對象]沒有方法'datepicker'

對象的翻譯:有沒有方法「日期選擇器」

我認爲這對jQuery Mobile的jQuery用戶界面之間的衝突,甚至做我沒有在日期選擇器頁面加載它。

使用jQuery Mobile的,它出現了幾個按鈕,

第一頁的PHP位 多了一個測試按鈕:

<a href="datepicker.php" type=button data-theme="b" data-role="button">test</a> 

datepicker.php:

<html lang="en"> 
<head> 
    <meta charset="utf-8"> 
    <title>jQuery UI Datepicker - Default functionality</title> 
    <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css"> 

    <script src="//code.jquery.com/jquery-1.9.1.js"></script> 
    <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script> 

</head> 
<body> 

<p>Date: <input type="text" id="datepicker"></p> 

<script type="text/javascript"> 
$("#datepicker").datepicker(); 

</script> 

</body> 
</html> 

我allrdy嘗試在幾個nonconflict方式但它沒有幫助:(

$(function() { 
var jq = $.noConflict(); 
    $("#datepicker").datepicker({}); 
    }); 

回答

0

它我因爲noConflict()調用,一旦你調用它$不再指jQuery。

也沒有必要把它稱爲DOM的準備,所以儘量

//call noConflict() 
var jq = $.noConflict(); 
//$ no longer refers to jQuery, so use the variable jQuery/jq to refer to jQuery 
jQuery(function ($) { 
    //the dom ready handler receices the jQuery instance as the parameter, so name it as $ so that we can use $ inside the handler to refer to jQuery 
    $("#datepicker").datepicker({}); 
}); 

演示:Fiddle

+0

我試過,沒有幫助仍geting相同的錯誤; / – user1246950

0

裝載有史以來頁面上的JS是問題
只需將其添加到索引頭

<script src=..js 

....

;/

相關問題