Pez*_*Pez 5 javascript twitter-bootstrap
我在rails应用程序中使用bootstrap.我试图使用bootstrap-modal显示对话框,但对话框不适合我.这是我的观看代码.
<div id="creative_attachment_popup" class="modal hide fade" role="dialog">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3>Modal header</h3>
</div>
<div class="modal-body">
<p>Do you eant to continue../p>
</div>
<div class="modal-footer">
<a href="#" class="btn">Close</a>
<a href="#" class="btn btn-primary">Save changes</a>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
简而言之,我将js文件称为
$('#creative_attachment_popup').modal('show');
Run Code Online (Sandbox Code Playgroud)
上面的代码只显示了一个淡入淡出的页面,并且不包含任何对话框.当我在控制台中键入上面的js行时,它显示以下内容:
<div id=?"creative_attachment_popup" class=?"modal hide fade in ui-dialog-content ui-widget-content" role=?"dialog"> <h1 style=?"display:? block;?" aria-hidden=?"false">?…?</div>?
Run Code Online (Sandbox Code Playgroud)
用我的html参考上面的代码.我为什么要这个?
你必须先包含jQuery.js,然后再包含bootstrap.js !!
并且不要使用简化形式的html脚本.(比如<script src=""/>)你必须关闭它像<script src=""></script>)
<!-- JQuery -->
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js'></script>
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js'></script>
<link rel="stylesheet" type="text/css" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css">
<!-- BootStrap Link -->
<link rel="stylesheet" type="text/css" href="/linker/styles/vendor/bootstrap.css">
<script type="text/javascript" src="/linker/js/vendor/bootstrap.js"></script>
Run Code Online (Sandbox Code Playgroud)
$('#creative_attachment_popup').modal('show');文件准备好后你打电话了吗?
$(function() {
$('#creative_attachment_popup').modal('show');
});
Run Code Online (Sandbox Code Playgroud)
检查以下内容:
我将您的代码复制并粘贴到空白页中,然后添加以下标题:
<link href="bootstrap.css" media="screen" rel="stylesheet" type="text/css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="bootstrap.js" type="text/javascript"></script>
Run Code Online (Sandbox Code Playgroud)
然后我跑了
$('#creative_attachment_popup').modal('show');
Run Code Online (Sandbox Code Playgroud)
奖牌弹出,上面有所有内容。所以我猜你可能没有包含所有内容(或者包含错误的内容)。
| 归档时间: |
|
| 查看次数: |
12639 次 |
| 最近记录: |