简体   繁体   English

引导模式显示在页面上,未隐藏

[英]Bootstrap modal displays on page, not hidden

I am having a problem with my bootstrap modal displaying inline with the html on the homepage of my site(AKA it is not invisible, it shows on the page). 我的引导程序模式与网站首页上的html内联显示时出现问题(又是不可见的,显示在页面上)。 I have open sourced this project, so it is available here to view: 我已经将此项目开源,因此可以在这里查看:

AdHoc Reporting Engine AdHoc报告引擎

This is a weird problem which suddenly popped up when I added panels to the page. 这是一个奇怪的问题,当我在页面中添加面板时突然弹出。

The following is my modal's code: 以下是我的模态代码:

        <!-- Placing excel upload modal here... -->
    @using (Html.BeginForm("UploadExcel", "Home", FormMethod.Post, new { enctype = "multipart/form-data", @class = "form-horizontal" })) {
        <div class="modal fade" id="excelModal" role="dialog">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal">&times;</button>
                        <h4 class="modal-title">Excel Upload</h4>
                    </div>
                    <div class="modal-body">
                        <p>Please upload an excel file that contains the data you are wishing to include in the report parameters.</p>
                    </div>
                    <div class="modal-footer">

                        <div>
                            <div class="form-group">
                                @Html.Label("Excel File:", new { @class = "control-label col-md-2" })
                                <div class="col-md-10">
                                    <input id="excelFile"
                                           name="excelFile"
                                           type="file" />
                                    <button class="btn btn-primary"
                                            type="button"
                                            ng-click="ExcelUpload()">
                                        Submit
                                    </button>
                                </div>
                            </div>
                        </div>

                        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                    </div>
                </div>
            </div>
        </div>
    }

The project is now open sourced, so you can download the whole thing. 该项目现已开放源代码,因此您可以下载整个内容。 You will just have to know how to set up an instance of OracleXE, the learner's (free) edition. 您将只需要知道如何设置学习者(免费)版OracleXE的实例。 The project itself is a form of reporting engine, difference being that the user actually has to browse out to it in order to get their report. 该项目本身是报告引擎的一种形式,不同之处在于用户实际上必须浏览到该项目才能获得他们的报告。

Correct me if I'm wrong but i'm not actually seeing where you hide the modal as default. 如果我错了,请纠正我,但实际上我没有看到默认情况下将模式隐藏的位置。 It is my understanding that modals are not hidden by default. 据我了解,默认情况下不会隐藏模式。 To the HTML compiler you are just making a regular modal that is shown to the user on page load. 对于HTML编译器,您只是制作一个常规模式,该模式在页面加载时显示给用户。

Something like: 就像是:

<div class="modal fade" id="excelModal" role="dialog" aria-hidden="true">

or 要么

<div class="modal fade" id="excelModal" role="dialog" hidden="true">

aria-hidden means: ARIA (Accessible Rich Internet Applications) defines a way to make Web content and Web applications more accessible to people with disabilities. aria-hidden的意思是:ARIA(可访问的丰富Internet应用程序)定义了一种使残障人士更易于访问Web内容和Web应用程序的方法。

per: What's the difference between HTML 'hidden' and 'aria-hidden' attributes? per: HTML的“隐藏”属性和“隐藏的aria”属性有什么区别?

And then to show the modal with jquery would be 然后用jquery显示模式是

$("#excelModal).modal('show')

Please let me know if I am wrong and you are hiding the modal. 如果我错了,请告诉我,您正在隐藏模式。 Or if there is a better way to hide and show modals. 或者,如果有更好的方法来隐藏和显示模态。 I'm learning too. 我也在学习。

You must call $('#excelModal').modal() at some point so the logic to turn it into a modal fires. 必须在某个时候调用$('#excelModal').modal() ,以便将其转换为模式触发的逻辑。

You just need to pass it an option to hide the modal until you show it via some event: 您只需要向它传递一个选项即可隐藏模式,直到通过某些事件显示它为止:

$('#excelModal').modal({
  show: false
})

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

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