4
我有一個啓動包含兩個TimePicker窗口小部件的模式窗口的頁面。打開第一個模式時,一切正常。它也可以重新打開。然而,打開另一個模式的時候,我得到一個控制檯錯誤:Yii2 Kartik TimePicker - 不能在多個模式窗口中使用
Uncaught TypeError: Cannot read property 'apply' of undefined
at HTMLInputElement.eval (eval at globalEval (jquery.js:343), <anonymous>:851:29)
at Function.each (jquery.js:365)
at jQuery.fn.init.each (jquery.js:137)
at jQuery.fn.init.$.fn.timepicker (eval at globalEval (jquery.js:343), <anonymous>:841:21)
at HTMLDocument.eval (eval at globalEval (jquery.js:343), <anonymous>:3:107)
at fire (jquery.js:3187)
at Object.add [as done] (jquery.js:3246)
at jQuery.fn.init.jQuery.fn.ready (jquery.js:3496)
at eval (eval at globalEval (jquery.js:343), <anonymous>:1:18)
at eval (<anonymous>)
這裏是代碼導致錯誤:
//TIMEPICKER PLUGIN DEFINITION
$.fn.timepicker = function (option) {
var args = Array.apply(null, arguments);
args.shift();
return this.each(function() {
var $this = $(this),
data = $this.data('timepicker'),
options = typeof option === 'object' && option;
if (!data) {
$this.data('timepicker', (data = new Timepicker(this, $.extend({}, $.fn.timepicker.defaults, options, $(this).data()))));
}
if (typeof option === 'string') {
data[option].apply(data, args); // This is the line that causes problems
}
});
};
下面是小部件中的PHP代碼:
<?= $form->field($model, 'TimeEntryStartTime',[
'showLabels'=>false
])->widget(TimePicker::classname(),[
'options' => ['placeholder' => 'Enter time...'],
]); ?>
這裏是啓動模式的JavaScript(每個類似):
// Modal view for Monday
$('#modalButtonMonday').click(function(){
// get the click of the create button
$('#modalMonday').modal('show')
.find('#modalContentMonday')
.load($(this).attr('value'));
});
$('#modalMonday').on('hidden.bs.modal', function (e) {
// reload page when modal closed
location.reload(true);
});
什麼在console.log(數據[選項])? – bxN5
這是未定義的。 –
所以你需要繼續轉儲找到女巫線腳本無法獲取數據,如果你有兩個模態的理智的身份證或類 – bxN5