0
當我在Modal中使用kartik \ date \ DatePicker時,但它的報告錯誤,如
https://******.com/assets/d9620747/css/bootstrap-datepicker3.css.map Failed to load resource: the server responded with a status of 404 (Not Found)
.plz幫助我;Yii2 Modal中的DatePicker
我的控制器代碼:
public function actionBook($id = null)
{
$ticket = $this->findModel($id);
$model = new TicketOrder();
if (Yii::$app->request->isPost && $model->load(Yii::$app->request->post())) {
// userCreate scenario
$model->scenario = 'create';
} else {
return $this->renderAjax('book', [
'ticket' => $ticket,
'model' => $model,
]);
}
}
我的視圖代碼:
<?php
Modal::begin([
'id' => 'create-modal',
'header' => '<h4 class="modal-title">訂票</h4>',
'size' => 'modal-lg',
// 'footer' => '<a href="#" class="btn btn-primary" data-dismiss="modal">Close</a>',
]);
Modal::end();
?>
<?php
$js = <<<JS
$(function(){
$(".modal-wraper").click(function(){
var id = $(this).attr('data-id');
var url = "/sights/product-ticket/book?id=" + id;
$.get(url,{},function(data){
$(".modal-body").html(data);
});
$('#create-modal').on('shown.bs.modal', function(){
$('[data-toggle="popover"]').popover();
});
$("#create-modal").modal('show');
});
});
JS;
$this->registerJs($js);
我ajaxRender視圖代碼:
<?php
use kartik\form\ActiveForm;
use kartik\date\DatePicker;
?>
<h3>由於資源方過多,建議一個手機號只購買一張票。</h3>
<?php
$form = ActiveForm::begin([
'type' => ActiveForm::TYPE_HORIZONTAL,
]);
?>
<?= $form->field($model, 'fullname')->textInput() ?>
<?= $form->field($model, 'mobile')->textInput() ?>
<?= $form->field($model, 'plantime')->widget(DatePicker::className(), [
'type' => DatePicker::TYPE_COMPONENT_APPEND,
]) ?>
<?= $form->field($model, 'comment')->textarea() ?>
<div class="button-group">
<?= \yii\helpers\Html::a('關閉', ['#'], ['class' => "btn btn-primary", 'data-dismiss' => "modal"]) ?>
<?= \yii\helpers\Html::button('購買', ['class' => 'btn btn-success pull-right', 'type' => 'submit']) ?>
</div>
<?php
$form->end();
?>
像這樣:
我點擊DatePicker按鈕時出錯。
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (bootstrap-datepicker3.css.map, line 0)
我的kartik-v/yii2-widget-datepicker版本已經是1.4.2,但它仍然報告錯誤,所以我請求幫助 –
最近你有更新到這個版本嗎?刪除生成的資產。 – Bizley
我清理資產並生成新資產時仍出現報告錯誤。 –