javascript - 将 DatePicker 添加到模态时出现问题 - 在背景中显示

标签 javascript jquery twitter-bootstrap datepicker

我正在尝试插入我在这里找到的 DatePicker:http://www.eyecon.ro/bootstrap-datepicker/但我无法让它显示在我的模态前面。 (我可以在模态的背景中看到它)

我不确定我是否错误地实现了它,或者我是否需要将其安装在模式显示的顶部。

这是我的 Bundle.config,我在其中添加了 datepicker.cssbootstrap-datapicker.js 文件。

public class BundleConfig
{
    // For more information on bundling, visit http://go.microsoft.com/fwlink/?LinkId=301862
    public static void RegisterBundles(BundleCollection bundles)
    {
        bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                    "~/Scripts/jquery-{version}.js"));

        bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
                    "~/Scripts/jquery.validate*"));

        // Use the development version of Modernizr to develop with and learn from. Then, when you're
        // ready for production, use the build tool at http://modernizr.com to pick only the tests you need.
        bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
                    "~/Scripts/modernizr-*"));

        bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
                  "~/Scripts/bootstrap.js",
                  "~/Scripts/respond.js"));

        bundles.Add(new StyleBundle("~/Content/css").Include(
                  "~/Content/bootstrap.css",
                  "~/Content/datepicker.css",
                  "~/Content/site.css"));

        bundles.Add(new ScriptBundle("~/bundles/myscript").Include(
                  "~/Scripts/MyScripts.js", "~/Scripts/bootstrap-datepicker.js"));
    }
}

这是我的模态

<div class="modal fade" id="createMovie" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
   <div class="modal-dialog">
      <div class="modal-content">
         <div class="modal-header" style="background-color: #428bca">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
            <h4 class="modal-title" id="myModalLabel" style="font-size: 30px; font-style:oblique; color:white">Create</h4>
         </div>
         <div class="modal-body">
            <table class="table" id="createTable">
               <tr>
                  <th class="col-lg-4">
                     <h5 style="font-size:x-large"><span style="font-weight:bolder">Title</span></h5>
                  </th>
                  <th class="col-lg-7 col-lg-offset-1">
                     <input type="text" name="createName" style="text-align: center; height: 35px; font-size: 20px; width: 100%" placeholder="Title" />
                  </th>
               </tr>
               <tr>
                  <th class="col-lg-4">
                     <h5 style="font-size:x-large"><span style="font-weight:bolder">Release Date</span></h5>
                  </th>
                  <th class="col-lg-7 col-lg-offset-1">
                     <input type="text" name="createRelease" id="datepicker" style="text-align:center; height:35px; font-size:20px; width:100%" placeholder="Date (mm/dd/yyyy)" />
                  </th>
               </tr>
               <tr>
                  <th class="col-lg-4">
                     <h5 style="font-size:x-large"><span style="font-weight:bolder">Description</span></h5>
                  </th>
                  <th class="col-lg-7 col-lg-offset-1">
                     <input type="text" name="createDescription" style="text-align:center; height:35px; font-size:20px; width:100%" placeholder="Description" />
                  </th>
               </tr>
            </table>
         </div>
         <div class="modal-footer">
            <button type="button" onclick="createFunction(this)" class="btn btn-success">Create</button>
            <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
         </div>
      </div>
   </div>
</div>

所以它“似乎”工作正常,只是我无法单击日历中出现在背景中的任何内容。

这是一张图片供引用 enter image description here

感谢所有帮助!

我对这方面的很多东西都很陌生,所以如果解决方案有点棘手,我们将欢迎详细的解释!:)

最佳答案

这是一个 CSS 问题:

模态日期选择器位于模态后面,因此:

CSS:

.datepicker{
    z-index: 1100 !important;
}

如果日期选择器小部件正常.ui-datepicker

关于javascript - 将 DatePicker 添加到模态时出现问题 - 在背景中显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24063191/

相关文章:

javascript - 如何使用jquery连续垂直滚动图像

javascript - 使用 forEach 和 axios 进行异步/等待

jquery ui 对话框在按钮前面添加图像

javascript - iframe css src 更改,如果父 css src 更改

javascript - CSS类相互冲突

javascript - 如何对隐藏的js脚本进行逆向工程?

javascript - 从 0 到 x 的 CSS 宽度转换导致内容压缩

javascript - 如何使用 JavaScript 定位 <article> 中的特定元素?

javascript - jquery 中的 HTML 标记

html - 如何创建具有 div 和不同列宽的表格?