[英]Yii2 popover-x within modal
我有一個像模態是 。 現在,我想將Kartik的Popover X添加到注入的表單中。
<div class="ensemble-form-add">
<?php
$content = '<p class="text-justify">sometext</p>';
echo PopoverX::widget([
'id' => 'ownShit',
'header' => 'Usage Information',
'size' => PopoverX::SIZE_LARGE,
'placement' => PopoverX::ALIGN_BOTTOM,
'content' => $content,
'toggleButton' => ['label'=>'<span class="glyphicon glyphicon-question-sign"></span>', 'class'=>'btn btn-lg btn-link'],
]); ?>
<?php $form = ActiveForm::begin(['id' => 'add ...
...
彈出按鈕和對話框(隱藏)正確呈現。 但是,點擊模式中的按鈕不會執行任何操作。 如果我單獨打開上面的表格(不是模態的),該按鈕將起作用並顯示對話框。
有人嘗試過嗎? 我必須設置ID才能正常工作嗎?
終於我得到了它的工作。 我使用了此鏈接中的代碼:
public static function renderLabelHelp($label, $help) {
return Html::tag('label', $label, [
'data-toggle'=>'popover',
'data-trigger' => 'click hover',
'data-placement' => 'auto right',
'data-html' => 'true', // allow html tags
// 'data-title'=> 'Help',
'data-content'=>$help,
'style'=>'border-bottom: 1px dashed #888; cursor:help;'
]);
}
並添加了以下js,使其具有魅力!
$(function(){
// this will show the popover within a modal window
$('#modal').on('shown.bs.modal', function(){
$('[data-toggle="popover"]').popover();
});
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.