Search code examples
ruby-on-railsformstwitter-bootstrapmodal-dialogclient-side-validation

ClientSideValidations Not Show in Twitter Bootstrap-Modal Rails 3.2


i using clientsidevalidations gem and twitter bootstrap-modal for my app. but vaidations not working.

on application.js

//= require bootstrap-modal

this is element for show in modal dialog

<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>

when i check the elements on chrome

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

I found some solutions but it did not help me

solution but not working to me and modal view

Are there any other solutions? thank's


Solution

  • You should be using SimpleForm and SimpleForm's Bootstrap integration. From there you can use client_side_validations-simple_form which supports Twitter Bootstrap