【发布时间】:2012-11-28 06:01:40
【问题描述】:
我解决了所有可能与 Twitter Bootstrap 模态相关的问题,但我的问题在这里有点独特。
我已经包含了来自最新引导程序版本的文件,所以我的公共目录有 -
css/
| bootstrap.css
| bootstrap.min.css
js/
| bootstrap.js
| bootstrap.min.js
我也在使用Select2,并且我检查过它不会干扰引导文件。
我的模态是这样定义的 -
<div class="modal hide fade" id="modal-<?php echo $user_role->id ?>" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3>Update “{{ $user_role->role_name }}”</h3>
</div>
<div class="modal-body">
<label>New Value</label>
<input type="hidden" name="inputId" value="<?php echo $user_role->id ?>">
<input type="text" name="inputUpdate" value="<?php echo $user_role->role_name ?>" autofocus>
</div>
<div class="modal-footer">
<a href="#" class="btn" data-dismiss="modal" aria-hidden="true">Cancel</a>
<a rel="update" href="<?php echo url('admin/dashboard/controls/update_master') ?>" class="btn btn-primary">Update</a>
</div>
</div>
而要调用模态,按钮是这样定义的-
<a rel="edit" data-toggle="modal" href="#modal-<?php echo $user_role->id ?>" class="btn btn-info">Edit</a>
页面上运行的JS是-
$(document).ready(function() {
var urlModal;
$('a[rel="edit"]').click(function() {
urlModal = $(this).attr('href');
$(urlModal).modal();
});
});
每当我点击<a rel="edit"> 按钮时,模态框就会出现并立即消失。
【问题讨论】:
-
你试过 $(urlModal).modal('show'); ?
-
刚刚解决了这个问题。非常白痴的我。让我把它放上来。
标签: php javascript twitter-bootstrap modal-dialog