Search code examples
ruby-on-railstwitter-bootstrapclient-side-validation

Rails client_side_validations inside a bootstrap modal


I'm trying to add the gem client_side_validations to my application. It works pretty fine if I go to something like controller/new, but, inside a bootstrap modal, it simply does nothing.

I inspected the HTML and it does not add the data-validate attribute. What should I do to fix this?


Solution

  • I just figured it out. In my coffeescript call, I do something like:

    $('.modal').on 'shown', ->
        $(this).find('input:visible:first').focus().end().find('form').enableClientSideValidations()
    

    This focus the first visible input, and enable the client side validations on the form.