2015-10-16 76 views
0

我嘗試在我的Symfony 2.7項目中使用jquery.datetimepicker,但是當我在我的視圖中調用datetimepicker時不加載日期和時間。控制檯顯示此錯誤:Uncaught TypeError:undefined不是函數jquery.datetimepicker.js:1619(匿名函數)

Uncaught TypeError: undefined is not a function jquery.datetimepicker.js:1619(anonymous function)

這是我的代碼:

<div class="contact"> 
        <div class="company_address"> 

         <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages.</p> 
        </div> 
        <div class="contact-form" > 
         {{ form(form) }} 
         <button type="submit" class="cancel" name="cancel" onclick="location.href = '{{ path('assistance_list') }}'">Cancel</button> 

        </div> 

        <div class="clear"></div> 
        <script> 
         $(document).ready(function() { 

          $.datetimepicker.setLocale('en'); 

          $("#daiquiri_daiquiribundle_assistance_date input").each(function() { 
           $(this).attr("readonly", "readonly"); 
          }); 

          $('#daiquiri_daiquiribundle_assistance_date_date').datetimepicker({ 
           format: "Y-m-d", 
           timepicker: false, 
           datepicker: true, 
           theme: 'dark' 
          }); 
          $('#daiquiri_daiquiribundle_assistance_date_time').datetimepicker({ 
           format: "H:i", 
           timepicker: true, 
           datepicker: false, 
           step: 10, 
           theme: 'dark' 
          }); 

         }); 
        </script> 
       </div> 
+0

您是否加載了jQuery UI Datepicker? 'datetimepicker'依賴於它。 – Barmar

+0

這是哪裏'daiquiri_daiquiribundle_assistance_date_date' –

+0

這是我想要加載datetimepicker的輸入的id。 – eliecerSR

回答

0

對不起,這個問題,這是我的錯誤,我想負荷:

<link rel="stylesheet" type="text/css" href="jquery.datetimepicker.css"/ > 
<script src="jquery.js"></script> 
<script src="jquery.datetimepicker.js"></script> 

當應加載:

<link rel="stylesheet" type="text/css" href="jquery.datetimepicker.css"/ > 
<script src="jquery.js"></script> 
*<script src="jquery.datetimepicker.full.js"></script>* 

這個改變解決了這個問題。 感謝大家的幫助。

0

當您使用表示函數名,你知道是一個jQuery方法名,並返回此錯誤,它是100 %代表您輸入錯誤,或者jQuery庫加載不正確。由於文檔準備工作,但沒有這種方法,它說,jQuery加載正確,但沒有爲datetimepicker方法的源庫。如果您使用的是Chrome,請按F12,然後檢查資源或控制檯。如果你有一個鏈接到控制檯,控制檯應該說「無法加載資源」,但這是不正確的。如果你還沒有裝好了的一切,你需要爲這些插件庫的位置:https://jqueryui.com/

相關問題