dpi10335 2018-07-19 07:54
浏览 117
已采纳

如何通过变量引导模态弹出窗口?

I am studying the bootstrap, and follow the example:

<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
    Shows the modal
</button>

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="false">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    模态框(Modal)标题
                </h4>
            </div>
            <div class="modal-body">
                在这里添加一些文本
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭
                </button>
                <button type="button" class="btn btn-primary">
                    提交更改
                </button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>

if I click the button the modal will popup, but I don't understand which variable is controlling the modal popup and disappear.

I want to through a variable to popup it. there is a requirement.

when I enter a Smarty page, if the page do not exists a access_token variable, I want the modal popup automatically.

So, how to realize in this example?

  • 写回答

2条回答 默认 最新

  • dqg95034 2018-07-20 03:57
    关注
    1. With JavaScript (jQuery), select the modal element and store it in variable.
    2. Trigger the show method.

      var myModal = $("#myModal");
      
      myModal.modal("show");
      
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵