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

        • <bdo id='f7rS2'></bdo><ul id='f7rS2'></ul>

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

        <legend id='f7rS2'><style id='f7rS2'><dir id='f7rS2'><q id='f7rS2'></q></dir></style></legend>
      1. 如何通过 Rails 中的 JS 请求显示 twitter 引导模式?

        时间:2023-06-13
      2. <small id='HmUOa'></small><noframes id='HmUOa'>

          <bdo id='HmUOa'></bdo><ul id='HmUOa'></ul>
            <tbody id='HmUOa'></tbody>

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

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

                  本文介绍了如何通过 Rails 中的 JS 请求显示 twitter 引导模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想显示一个 twitter 引导模式作为对 JS 请求的响应.我的 show.js.erb 函数看起来像这样:

                  I want to show a twitter bootstrap modal as a response to a JS request. My show.js.erb function looks something like this:

                  $(document).ready(function() {
                  
                      $('#dialog').modal('show')
                  
                  });
                  

                  这里的对话框"是模态的 id.模态代码本身看起来像这样:

                  Here "dialog" is the modal's id. The modal code itself looks something like this:

                  <div id="dialog" class="modal hide fade">
                      <div class="modal-header">
                            <a href="#" class="close">&times;</a>
                            <h3> Showing Modal </h3>
                      </div>
                      <div class="modal-body">
                          I need to show up!
                      </div>
                      <div class="modal-footer">
                          <a href="#" class="btn primary">Done</a>
                      </div>
                  </div>
                  

                  我可以确定的一件事是正在调用 javascript.我可以让它改变页面上的项目.另一件事是模态工作正常.当我使用 HTML 按钮触发这样的请求时,它显示得很好:

                  One thing I am sure of is that the javascript is being called. I can have it alter items on the page. Another thing is that modal is working fine. It shows up just fine when I use an HTML button to trigger the request like this:

                  <button data-controls-modal="dialog" data-backdrop="true" data-keyboard="true" class="btn danger"> Show </button>
                  

                  知道为什么模态不会出现在 JS 请求中吗?

                  Any idea why the modal doesn't show up on JS request?

                  谢谢!

                  推荐答案

                  我也遇到过类似的问题,稍作改动就解决了

                  I had a similar problem, which I solved with a slight twist

                  我的模态 div 呈现在调用页面上(来自部分),而不是由 JS 请求的响应:

                  My modal div is rendered on the calling page (from a partial) and not by the response of the JS request:

                  <div class="modal hide fade" id="modal-window">
                    <div class="modal-header">
                      <a href="#" class="close">×</a>
                      <h3>Loading...</h3>
                    </div>
                    <div class="modal-body center">
                        <%= image_tag "loading.gif" %>
                    </div>
                    <div class="modal-footer">&nbsp;</div>
                  </div>
                  

                  我使用这个链接依赖rails和Twitter不显眼的JS:

                  I use this link to rely on rails and Twitter unobtrusive JS:

                  <%= link_to negotiation.name, negotiation_path(negotiation), {:remote => true, 'data-controls-modal' =>  "modal-window", 'data-backdrop' => true, 'data-keyboard' => true} %>
                  

                  我的 show.js.erb 看起来像这样(缩短)

                  and my show.js.erb looks like this (shortened)

                  $('.modal-body').html('<%= escape_javascript(render :partial => 'negotiationdetail', :object => @negotiation) %>');
                  $('.modal-header').remove(); // don't need a header here
                  

                  这很好用,并且可以在填充模式时向用户显示加载"动画.

                  This works fine and has the benefit of showing a "loading" animation to the user while the modal is being populated.

                  这篇关于如何通过 Rails 中的 JS 请求显示 twitter 引导模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:将 div 显示为模态弹出窗口 下一篇:jQuery中的简单模态div?

                  相关文章

                • <tfoot id='COM90'></tfoot>
                • <legend id='COM90'><style id='COM90'><dir id='COM90'><q id='COM90'></q></dir></style></legend>

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

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

                      • <bdo id='COM90'></bdo><ul id='COM90'></ul>