简体   繁体   English

通过脚本函数调用引导程序模式对话框

[英]call bootstrap modal dialog through script function

In my html page, now I open modal dialog in this way 在我的html页面中,现在我以这种方式打开模式对话框

Modal Call button 模态通话按钮

<a class="btn btn-primary btn-xs" data-toggle="modal" data-target="#editBox" href="file.php?id=<?php echo $obj->id;?>">

The following html code in page 页面中的以下html代码

<div class="modal fade" id="editBox" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
          //Content Will show Here
        </div>
    </div>
</div>

And this is file.php 这是file.php

<?php
$Id = $_GET["id"];
?>
<div class="modal-header">
    <button type="button" class="close" data-dismiss="modal">&times;</button>
    <h4 class="modal-title"><center>Heading</center></h4>
</div>
<div class="modal-body">
    //Show records fetched from database against $Id
</div>
<div class="modal-footer">
    <button type="button" class="btn btn-default">Submit</button>
    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>

What if I need to call the modal through script function ? 如果我需要通过脚本函数调用模式该怎么办?

I have this 我有这个

eventClick: function (result) {

   // call the dialog passing $id
})

EDIT 编辑

I need to pass $id value 我需要传递$ id值

Now I call the dialog with 现在我用

href="file.php?id=<?php echo $obj->id;?>"

You can specify the url to load when opening the modal with the remote option: 您可以使用remote选项打开模式时指定要加载的网址:

$('#editBox').modal({
    remote: url + "?id=" + id, 
    show: true
});

The current recommendation is to use ajax to load the content rather than use the remote: option - this will be removed in later versions of bootstrap. 当前建议使用ajax加载内容,而不是使用remote:选项-在更高版本的引导程序中将删除此选项。

Source: http://getbootstrap.com/javascript/#via-javascript 来源: http : //getbootstrap.com/javascript/#via-javascript

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM