我使用的是Admin LTE 3.0和yii2fullcalendar v3.9.0。
现在我想用一个脚本来设置yii2fullcalendar,这个脚本可以获取我在日历上点击的日期,并显示一个模态形式来创建已经设置好的日期的事件。
问题是模态不显示,因为adminlte.css引起了故障。请看下面的图片
下面是代码
CalendarioAsset.php
<?php
namespace app\assets;
use yii\web\AssetBundle;
class CalendarioAsset extends AssetBundle
{
public $basePath = '@webroot';
public $baseUrl = '@web';
public $css = [
'css/calendario/site.css',
];
public $js = [
'js/calendario/createEvent.js',
'js/jquery.min.js'
];
public $depends = [
'yii\web\YiiAsset',
'yii\web\JqueryAsset',
'yii\bootstrap\BootstrapAsset',
];
}
DashboardAsset.php
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace app\assets;
use yii\web\AssetBundle;
/**
* Main application asset bundle.
*
* @author Qiang Xue <[email protected]>
* @since 2.0
*/
class DashboardAsset extends AssetBundle
{
public $basePath = '@webroot';
public $baseUrl = '@web';
public $css = [
'css/site.css',
'css/all.min.css',
'css/OverlayScrollbars.min.css',
'css/adminlte.css',
'https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700'
];
public $js = [
'js/jquery.min.js',
'js/bootstrap.bundle.min.js',
'js/jquery.overlayScrollbars.min.js',
'js/adminlte.js',
'js/demo.js',
'js/jquery.mousewheel.js',
'js/raphael.min.js',
'js/jquery.mapael.min.js',
'js/usa_states.min.js',
'js/Chart.min.js',
'js/dashboard2.js'
];
public $depends = [
'yii\web\YiiAsset',
'yii\web\JqueryAsset',
'yii\bootstrap\BootstrapAsset',
];
}
查看index.php
<?php
use yii\helpers\Html;
use yii\bootstrap\Modal;
use app\assets\CalendarioAsset;
use yii\web\JsExpression;
CalendarioAsset::register($this);
/* @var $this yii\web\View */
/* @var $searchModel app\models\CalendarioSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Calendario de Reuniones';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="calendario-index">
<h1><?= Html::encode($this->title) ?></h1>
<p>
<?= Html::a('Ver lista', ['lista'], ['class' => 'btn btn-success']) ?>
<?= Html::a('Crear Reunión', ['create_lista'], ['class' => 'btn btn-success']) ?>
</p>
<p>
<?php
Modal::begin([
'header' => '<h3>Crear Evento</h3>',
'id'=>'create',
'size'=>'modal-lg',
]);
echo "<div id='modalCreate'></div>";
Modal::end();
?>
</p>
<p>
<?php
Modal::begin([
'header' => '<h3>Información del evento</h3>',
'id'=>'view',
'size'=>'modal-lg',
]);
echo "<div id='modalView'></div>";
Modal::end();
?>
</p>
<p>
<?php
Modal::begin([
'header' => '<h3>Actualizar evento</h3>',
'id' => 'update',
'size' => 'modal-lg'
]);
echo "<div id='modalUpdate'></div>";
Modal::end();
?>
</p>
<p>
<?php
$JsEventClick = 'function(event) {
$.get("index.php?r=calendario/view", {"id": event.id}, function(data){
$("#view").modal("show")
.find("#modalView")
.html(data);
});
}'
?>
</p>
<p>
<?php
$JsEventDrop = 'function(event, delta, revertFunc) {
var event_data = {
id: event.id,
fecha_inicio: $.fullCalendar.formatDate(event.start, "YYYY-MM-DD"),
hora_inicio: $.fullCalendar.formatDate(event.start, "HH:mm"),
hora_termino: $.fullCalendar.formatDate(event.end, "HH:mm"),
fecha_termino: $.fullCalendar.formatDate(event.end, "YYYY-MM-DD"),
};
if (!confirm("¿Está seguro que desea modificar la fecha y/o hora?")) {
revertFunc();
}
else {
$.ajax({
type: "POST",
url: "index.php?r=calendario/update-drop" + "&id=" + event_data.id
+ "&fecha_inicio=" + event_data.fecha_inicio + "&hora_inicio=" + event_data.hora_inicio
+ "&hora_termino=" + event_data.hora_termino + "&fecha_termino=" + event_data.fecha_termino,
success: function(json) {
alert("Fecha y/o hora modificada correctamente");
}
});
}
}'
?>
</p>
<p>
<?php
$JsEventResize = 'function(event, delta, revertFunc) {
var event_data = {
id: event.id,
hora_inicio: $.fullCalendar.formatDate(event.start, "HH:mm"),
hora_termino: $.fullCalendar.formatDate(event.end, "HH:mm"),
};
if (!confirm("¿Está seguro que desea modificar la hora?")) {
revertFunc();
}
else {
$.ajax({
type: "POST",
url: "index.php?r=calendario/update-resize" + "&id=" + event_data.id
+ "&hora_inicio=" + event_data.hora_inicio + "&hora_termino=" + event_data.hora_termino,
success: function(json) {
alert("Hora modificada correctamente");
}
});
}
}'
?>
</p>
<p>
<?php
$JsEventRender = 'function(event, element){
element.popover({
title: "Descripción",
animation:true,
delay: 300,
placement: "top",
content: event.description,
trigger: "hover",
container: "body",
});
}'
?>
</p>
<p>
<?= yii2fullcalendar\yii2fullcalendar::widget([
'events' => $events,
'id' => 'calendario',
'options' => [
'lang' => 'es',
],
'clientOptions' => [
'selectable' => false,
'editable' => true,
'droppable' => true,
'header' => [
'left' => 'prev,next,today',
'center' => 'title',
'right' => 'month,agendaWeek,agendaDay,listDay',
],
'minTime' => '08:00',
'maxTime' => '21:00',
'height' => 'auto',
'snapDuration' => '00:05:00',
'eventRender' => new JsExpression($JsEventRender),
'eventClick' => new JsExpression($JsEventClick),
'eventDrop' => new JsExpression($JsEventDrop),
'eventResize' => new JsExpression($JsEventResize),
],
]);
?>
</p>
</div>
这就是问题所在,它并没有坏,只是不显示模式。主窗口淡出,但模态不显示。
calendariosite.css
.modal {
overflow-y: scroll!important;
overflow-x: visible;
display: block;
overflow: scroll;
}
.modal-header {
border-bottom: 0 none;
padding-bottom: 0px;
}
.modal-body {
padding-top: 0px;
padding-bottom: 0px;
}
.modal-open {
overflow: scroll;
overflow-x: visible;
overflow-y: scroll!important;
}
.modal-content{
overflow: scroll;
}
adminlte.css
.modal-open {
overflow: hidden;
}
.modal-open .modal {
overflow-x: hidden;
overflow-y: auto;
}
.modal {
position: fixed;
top: 0;
left: 0;
z-index: 1050;
display: none;
width: 100%;
height: 100%;
overflow: hidden;
outline: 0;
}
.modal-dialog {
position: relative;
width: auto;
margin: 0.5rem;
pointer-events: none;
}
.modal.fade .modal-dialog {
transition: -webkit-transform 0.3s ease-out;
transition: transform 0.3s ease-out;
transition: transform 0.3s ease-out, -webkit-transform 0.3s ease-out;
-webkit-transform: translate(0, -50px);
transform: translate(0, -50px);
}
@media (prefers-reduced-motion: reduce) {
.modal.fade .modal-dialog {
transition: none;
}
}
.modal.show .modal-dialog {
-webkit-transform: none;
transform: none;
}
.modal-dialog-scrollable {
display: -ms-flexbox;
display: flex;
max-height: calc(100% - 1rem);
}
.modal-dialog-scrollable .modal-content {
max-height: calc(100vh - 1rem);
overflow: hidden;
}
.modal-dialog-scrollable .modal-header,
.modal-dialog-scrollable .modal-footer {
-ms-flex-negative: 0;
flex-shrink: 0;
}
.modal-dialog-scrollable .modal-body {
overflow-y: auto;
}
.modal-dialog-centered {
display: -ms-flexbox;
display: flex;
-ms-flex-align: center;
align-items: center;
min-height: calc(100% - 1rem);
}
.modal-dialog-centered::before {
display: block;
height: calc(100vh - 1rem);
content: "";
}
.modal-dialog-centered.modal-dialog-scrollable {
-ms-flex-direction: column;
flex-direction: column;
-ms-flex-pack: center;
justify-content: center;
height: 100%;
}
.modal-dialog-centered.modal-dialog-scrollable .modal-content {
max-height: none;
}
.modal-dialog-centered.modal-dialog-scrollable::before {
content: none;
}
.modal-content {
position: relative;
display: -ms-flexbox;
display: flex;
-ms-flex-direction: column;
flex-direction: column;
width: 100%;
pointer-events: auto;
background-color: #ffffff;
background-clip: padding-box;
border: 1px solid rgba(0, 0, 0, 0.2);
border-radius: 0.3rem;
box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.5);
outline: 0;
}
.modal-backdrop {
position: fixed;
top: 0;
left: 0;
z-index: 1040;
width: 100vw;
height: 100vh;
background-color: #000;
}
.modal-backdrop.fade {
opacity: 0;
}
.modal-backdrop.show {
opacity: 0.5;
}
.modal-header {
display: -ms-flexbox;
display: flex;
-ms-flex-align: start;
align-items: flex-start;
-ms-flex-pack: justify;
justify-content: space-between;
padding: 1rem;
border-bottom: 1px solid #e9ecef;
border-top-left-radius: 0.3rem;
border-top-right-radius: 0.3rem;
}
.modal-header .close, .modal-header .mailbox-attachment-close {
padding: 1rem;
margin: -1rem -1rem -1rem auto;
}
.modal-title {
margin-bottom: 0;
line-height: 1.5;
}
.modal-body {
position: relative;
-ms-flex: 1 1 auto;
flex: 1 1 auto;
padding: 1rem;
}
.modal-footer {
display: -ms-flexbox;
display: flex;
-ms-flex-align: center;
align-items: center;
-ms-flex-pack: end;
justify-content: flex-end;
padding: 1rem;
border-top: 1px solid #e9ecef;
border-bottom-right-radius: 0.3rem;
border-bottom-left-radius: 0.3rem;
}
.modal-footer > :not(:first-child) {
margin-left: .25rem;
}
.modal-footer > :not(:last-child) {
margin-right: .25rem;
}
.modal-scrollbar-measure {
position: absolute;
top: -9999px;
width: 50px;
height: 50px;
overflow: scroll;
}
@media (min-width: 576px) {
.modal-dialog {
max-width: 500px;
margin: 1.75rem auto;
}
.modal-dialog-scrollable {
max-height: calc(100% - 3.5rem);
}
.modal-dialog-scrollable .modal-content {
max-height: calc(100vh - 3.5rem);
}
.modal-dialog-centered {
min-height: calc(100% - 3.5rem);
}
.modal-dialog-centered::before {
height: calc(100vh - 3.5rem);
}
.modal-content {
box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.5);
}
.modal-sm {
max-width: 300px;
}
}
@media (min-width: 992px) {
.modal-lg,
.modal-xl {
max-width: 800px;
}
}
@media (min-width: 1200px) {
.modal-xl {
max-width: 1140px;
}
}
我不知道如何编辑adminlte.css来显示日历的模式。
以及对于视线有一些冲突之间的js文件,所以,如果你能提供给我一个错误的控制台,看看发生了什么事,否则,我已经看到在你的consol一点点的红色,这意味着有一些错误,我的建议是删除资产的管理LTE永久和尝试,如果模型是工作的