• <tfoot id='FS8Pm'></tfoot>

  • <legend id='FS8Pm'><style id='FS8Pm'><dir id='FS8Pm'><q id='FS8Pm'></q></dir></style></legend>

      1. <i id='FS8Pm'><tr id='FS8Pm'><dt id='FS8Pm'><q id='FS8Pm'><span id='FS8Pm'><b id='FS8Pm'><form id='FS8Pm'><ins id='FS8Pm'></ins><ul id='FS8Pm'></ul><sub id='FS8Pm'></sub></form><legend id='FS8Pm'></legend><bdo id='FS8Pm'><pre id='FS8Pm'><center id='FS8Pm'></center></pre></bdo></b><th id='FS8Pm'></th></span></q></dt></tr></i><div id='FS8Pm'><tfoot id='FS8Pm'></tfoot><dl id='FS8Pm'><fieldset id='FS8Pm'></fieldset></dl></div>
      2. <small id='FS8Pm'></small><noframes id='FS8Pm'>

        • <bdo id='FS8Pm'></bdo><ul id='FS8Pm'></ul>
      3. 如何使用 javascript 隐藏 Bootstrap 模式?

        时间:2023-06-13

          1. <legend id='XG31T'><style id='XG31T'><dir id='XG31T'><q id='XG31T'></q></dir></style></legend>

              <i id='XG31T'><tr id='XG31T'><dt id='XG31T'><q id='XG31T'><span id='XG31T'><b id='XG31T'><form id='XG31T'><ins id='XG31T'></ins><ul id='XG31T'></ul><sub id='XG31T'></sub></form><legend id='XG31T'></legend><bdo id='XG31T'><pre id='XG31T'><center id='XG31T'></center></pre></bdo></b><th id='XG31T'></th></span></q></dt></tr></i><div id='XG31T'><tfoot id='XG31T'></tfoot><dl id='XG31T'><fieldset id='XG31T'></fieldset></dl></div>

            1. <small id='XG31T'></small><noframes id='XG31T'>

              <tfoot id='XG31T'></tfoot>
                  <tbody id='XG31T'></tbody>
                  <bdo id='XG31T'></bdo><ul id='XG31T'></ul>
                • 本文介绍了如何使用 javascript 隐藏 Bootstrap 模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我已经阅读了这里的帖子、Bootstrap 网站,并且疯狂地在 Google 上搜索 - 但找不到我确定的简单答案...

                  我有一个 Bootstrap 模式,我可以从这样的 link_to 助手打开它:

                  <%= link_to "新联系人", new_contact_path, {remote: true, 'data-toggle' =>'模态','数据目标' =>#myModal",类:btn btn-primary"} %>

                  在我的 ContactsController.create 操作中,我有创建 Contact 然后传递给 create.js.erb 的代码.在 create.js.erb 中,我有一些错误处理代码(ruby 和 javascript 的混合).如果一切顺利,我想关闭模态框.

                  这就是我遇到麻烦的地方.当一切顺利时,我似乎无法关闭模态.

                  我试过 $('#myModal').modal('hide'); 这没有效果.我也试过 $('#myModal').hide(); 导致模态消失但离开背景.

                  关于如何在 create.js.erb 中关闭模式和/或关闭背景的任何指导?

                  编辑

                  这是 myModal 的标记:

                  解决方案

                  在浏览器窗口打开modal,使用浏览器的控制台试试

                  $('#myModal').modal('hide');

                  如果它有效(并且模式关闭),那么您知道您关闭的 Javascript 没有正确地从服务器发送到浏览器.

                  如果它不起作用,那么您需要在客户端上进一步调查发生了什么.例如,确保没有两个元素具有相同的 id.例如,它在页面加载后第一次工作但第二次不工作?

                  浏览器的控制台:firefox的firebug,Chrome或Safari的调试控制台等

                  I've read the posts here, the Bootstrap site, and Googled like mad - but can't find what I'm sure is an easy answer...

                  I have a Bootstrap modal that I open from a link_to helper like this:

                  <%= link_to "New Contact", new_contact_path, {remote: true, 'data-toggle' => 'modal', 'data-target' => "#myModal",  class: "btn btn-primary"} %>
                  

                  In my ContactsController.create action, I have code that creates Contact then passes off to create.js.erb. In create.js.erb, I have some error handling code (a mix of ruby and javascript). If everything goes well, I want to close the modal.

                  This is where I'm having trouble. I can't seem to dismiss the modal when all goes well.

                  I've tried $('#myModal').modal('hide'); and this has no effect. I've also tried $('#myModal').hide(); which causes the modal to dismiss but leaves the backdrop.

                  Any guidance on how to close the modal and/or dismiss the backdrop from within create.js.erb?

                  Edit

                  Here's the markup for myModal:

                  <div class="modal hide" id="myModal" >
                    <div class="modal-header">
                      <a class="close" data-dismiss="modal">×</a>
                      <h3>Add Contact</h3>
                      <div id="errors_notification">
                      </div>
                    </div>
                    <div class="modal-body">
                      <%= form_for :contact, url: contacts_path, remote: true do |f| %>  
                        <%= f.text_field :first_name, placeholder: "first name" %>
                        <%= f.text_field :last_name, placeholder: "last name" %>
                        <br>
                        <%= f.submit "Save", name: 'save', class: "btn btn-primary" %>
                        <a class="close btn" data-dismiss="modal">Cancel</a>
                      <% end %>
                    </div>
                    <div class="modal-footer">
                    </div>
                  </div>
                  

                  解决方案

                  With the modal open in the browser window, use the browser's console to try

                  $('#myModal').modal('hide');
                  

                  If it works (and the modal closes) then you know that your close Javascript is not being sent from the server to the browser correctly.

                  If it doesn't work then you need to investigate further on the client what is happening. Eg make sure that there aren't two elements with the same id. Eg does it work the first time after page load but not the second time?

                  Browser's console: firebug for firefox, the debugging console for Chrome or Safari, etc.

                  这篇关于如何使用 javascript 隐藏 Bootstrap 模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                    <tbody id='oIVMy'></tbody>

                        <i id='oIVMy'><tr id='oIVMy'><dt id='oIVMy'><q id='oIVMy'><span id='oIVMy'><b id='oIVMy'><form id='oIVMy'><ins id='oIVMy'></ins><ul id='oIVMy'></ul><sub id='oIVMy'></sub></form><legend id='oIVMy'></legend><bdo id='oIVMy'><pre id='oIVMy'><center id='oIVMy'></center></pre></bdo></b><th id='oIVMy'></th></span></q></dt></tr></i><div id='oIVMy'><tfoot id='oIVMy'></tfoot><dl id='oIVMy'><fieldset id='oIVMy'></fieldset></dl></div>
                          <bdo id='oIVMy'></bdo><ul id='oIVMy'></ul>

                          <small id='oIVMy'></small><noframes id='oIVMy'>

                        • <tfoot id='oIVMy'></tfoot>

                          <legend id='oIVMy'><style id='oIVMy'><dir id='oIVMy'><q id='oIVMy'></q></dir></style></legend>