2013-07-31 22 views
0

我是很新的Javascript和我想執行這個stockchart從這個URL做工精細:http://jsfiddle.net/2zBRt/2/的Javascript stockchart圖

 The code is excatly the same from the URL, some minor changes are made to ensure that the JQuery library is called 

不過,我不斷收到此錯誤:

(1) Uncaught TypeError: Cannot call method 'setDefaults' of undefined

(2) Uncaught TypeError: Object [object Object] has no method 'datepicker'

Code: 
    function(chart){ 

      // apply the date pickers 
      setTimeout(function(){ 
       $('input.highcharts-range-selector', 

$('#'+chart.options.chart.renderTo)).datepicker() 
      },0) 

    }); 


    // Set the datepicker's date format 
    $.datepicker.setDefaults({ 
     dateFormat: 'yy-mm-dd', 
     onSelect: function(dateText) { 
      this.onchange(); 
      this.onblur(); 
     } 
    }); 

請幫助我,我的老闆呼吸嚴重下來我的脖子

回答

0

因爲我知道W,這兩個函數沒有定義呢,所以說功能取消定義

setTimeout(function(){ 
    $('input.highcharts-range-selector', 
    $('#'+chart.options.chart.renderTo)).datepicker() 
},0) 

此功能使用日期選擇器()函數,但它並沒有定義之前

$.datepicker.setDefaults({ 
     dateFormat: 'yy-mm-dd', 
     onSelect: function(dateText) { 
      this.onchange(); 
      this.onblur(); 
     } 

同樣的問題,沒有按「T定義尚未

+0

我如何定義函數? –

+0

看來,datepicker是一個CLASS,setDefaults是datepicker的方法,或者乾脆刪除這兩個函數,圖表仍然工作 –

0

請確保您有jQuery的和jQuery UI的兼容版本,例如在適當的jsfiddle包括時,它工作正常,請參閱:http://jsfiddle.net/2zBRt/41/