Max*_*Boy 0 javascript coldfusion twitter-bootstrap
如果我的项目位于不同的文件(modals.cfm)中,我将创建所有模态。如何从另一个文件调用模式?
modals.cfm(引导模态示例)
<div class="modal fade" id="requestError" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button aria-hidden="true" data-dismiss="modal" class="close" type="button">X</button>
<h4 id="myModalLabel1" class="modal-title"><strong>Error!</strong></h4>
</div>
<div class="modal-body">
<div class="alert alert-danger fade in">
<h2 id="error"></h2>
</div>
</div>
<div class="modal-footer">
<button data-dismiss="modal" class="btn btn-default" type="button">Close</button>
<button data-dismiss="modal" class="btn btn-primary" type="button" onClick="myFunc();">Confirm</button>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
然后,我想从另一个 cfm 文件中调用它。例如,index.cfm:
<button type="button" class="btn btn-primary" onClick="callModal();"> Test </button>
<script>
function callModal(){
$("#error").html("My custom error message");
$("#requestError").modal(); // How can I call it from another file?
}
</script>
Run Code Online (Sandbox Code Playgroud)
是否可以?
谢谢
帮助我理解 ColdFusion 的更“基本”的事情之一是这样思考:ColdFusion 的目的是生成 HTML。
现在,根据您的描述,您说您想使用在modals.cfm
. 很好,但是如何将其插入到您现在所在的页面上(例如:index.cfm
)?
index.cfm
一种简单、直接的方法是对 modals.cfm执行 CFINCLUDE :
<!-- index.cfm code here--->
<button type="button" class="btn btn-primary" onClick="callModal();"> Test </button>
<cfinclude template="modals.cfm">
<script>
function callModal(){
$("#error").html("My custom error message");
$("#requestError").modal(); // How can I call it from another file?
}
</script>
Run Code Online (Sandbox Code Playgroud)
如果你想通过 AJAX 加载页面(正如 James 上面提到的),这会需要更多的工作,但绝对可行。我们只需要更多代码。
归档时间: |
|
查看次数: |
1279 次 |
最近记录: |