1
我的datepicker在一個文件中工作正常,但在另一個文件中根本不起作用。有人能指出問題是什麼嗎?jQuery UI Datepicker不起作用
這裏是工作的日期選擇器的代碼:
<script type="text/javascript">
$(document).ready(function(){
$('.date').datepicker({
changeYear: true,
changeMonth: true,
dateFormat: "dd.mm.yy",
minDate: new Date(1950, 1 - 1, 1),
maxDate: new Date(),
yearRange: "1900:2015",
closeText: "Zamknij",
dayNames: [ "Dimanche", "Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi" ],
monthNames: [ "Styczeń", "Luty", "Marzec", "Kwiecień", "Maj", "Czerwiec", "Lipiec", "Sierpień", "Wrzesień", "Październik", "Listopad", "Grudzień" ],
monthNamesShort: [ "Sty", "Lut", "Mar", "Kwie", "Maj", "Cze", "Lip", "Sie", "Wrz", "Paź", "Lis", "Gru" ]
});
});
而且我在這裏使用它:
<div class="form-group ">
<label class="col-sm-2" for="Client_birth_date">
<?php echo $registerForm->labelEx($registerModel, 'birth_date'); ?>
</label>
<div class="col-sm-10">
<?php echo $registerForm->textField($registerModel, 'birth_date', array('class' => 'input_form input_grup date form-control')); ?>
<?php echo $registerForm->error($registerModel, 'birth_date'); ?>
</div>
</div>
,它工作得很好。
但在另一個文件中我有相同的代碼,但它根本不起作用。
腳本:
<script type="text/javascript">
$(document).ready(function(){
$('#display-files').click(function(){
$('#files-modal').modal({show:true});
});
});
<script type="text/javascript">
$(document).ready(function(){
$('.date').datepicker({
changeYear: true,
changeMonth: true,
dateFormat: "dd.mm.yy",
minDate: new Date(1950, 1 - 1, 1),
maxDate: new Date(),
yearRange: "1900:2015",
closeText: "Zamknij",
dayNames: [ "Dimanche", "Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi" ],
monthNames: [ "Styczeń", "Luty", "Marzec", "Kwiecień", "Maj", "Czerwiec", "Lipiec", "Sierpień", "Wrzesień", "Październik", "Listopad", "Grudzień" ],
monthNamesShort: [ "Sty", "Lut", "Mar", "Kwie", "Maj", "Cze", "Lip", "Sie", "Wrz", "Paź", "Lis", "Gru" ]
});
});
<script type="text/javascript">
$(document).ready(function(){
$('#display-tags').click(function(){
$('#tags-modal').modal({show:true});
});
});
和地點,我使用它:
<?= $aditionalCostForm->labelEx($aditionalCostModel, 'date'); ?>
<?= $aditionalCostForm->textField($aditionalCostModel, 'date', array(
'class' => 'form-control btn-rect',
)); ?>
任何解決方案?我會很感激。
檢查控制檯是否有錯誤。你包括正確的jQuery和datepicker庫嗎? –
_「不起作用」_並沒有告訴我們很多。控制檯中有任何錯誤? –
如果你需要日期選擇器爲模態的內容工作,我建議你確保代碼在模態顯示後運行(取決於框架,這是通過事件或回調參數)。日期字段可能不在文檔準備好的頁面中。 – apokryfos