ClientSideValidations不显示在Twitter Bootstrap-Modal Rails 3.2中

时间:2012-12-18 08:29:46

标签: ruby-on-rails forms twitter-bootstrap modal-dialog client-side-validation

我使用clientidevalidations gem和twitter bootstrap-modal为我的应用程序。 但是没有工作。

on application.js

//= require bootstrap-modal

这是模态对话框中显示的元素

<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" >

  <%= form_for @content, :validate => true do |f| %>
  <script>$('#new_content').validate()</script>
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
    <h3 id="myModalLabel">New Content</h3>
  </div>
  <div class="modal-body" style = "height:600px;overflow-y: scroll;">

  <div class="field">
    <%= f.label :name %><br />
    <%= f.text_field :name %>
  </div>
  <div class="field">
    <%= f.label :permalink, "Permalink" %><br />
    <%= f.text_field :permalink %>
  </div>
  <div class="field">
    <%= f.label :body %><br />
    <%= f.text_area :body, :class => "redactor", :rows => 10, :cols => 40 %>
  </div>
  </div>
  <div class="modal-footer">
    <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>&nbsp;&nbsp; atau &nbsp;&nbsp;
    <%= f.submit ( "Submit" ), :class => "btn btn-inverse btn-medium" %>
  </div>

  </div>
  <% end %>

</div>

当我检查chrome上的元素时

<form accept-charset="UTF-8" action="/admin/contents" class="new_content" data-validate="true" id="new_content" method="post" novalidate="novalidate">

我找到了一些解决方案,但它没有帮助我

solution but not working to memodal view

还有其他解决方案吗? 感谢的

2 个答案:

答案 0 :(得分:5)

附加验证处理程序时输入字段不可见的问题。有关详细信息和修复,请参阅SimpleForm+ClientSideValidations+bootstrap - Validation is not occuring on the form- all inputs are accepted

答案 1 :(得分:0)

您应该使用SimpleForm和SimpleForm的Bootstrap集成。从那里你可以使用支持Twitter Bootstrap的client_side_validations-simple_form