DavyJonesLocker / client_side_validations

Client Side Validations made easy for Ruby on Rails
MIT License
2.69k stars 404 forks source link

Configure client_side_validations on rails 5.0 #730

Closed mquispe1185 closed 6 years ago

mquispe1185 commented 6 years ago

I can show validations messages correctly in a normal form but NOT IN MODAL FORM. the solutions in the wiki seems not to work in rails 5.0 as they show a solution for Rails 5.1. this are my gems client_side_validations (11.0.0) client_side_validations-simple_form (6.5.0) rails (5.0.6, 5.0.3, 5.0.2) bootstrap-sass (3.3.7)

this is my aplication.js `$(document).on('turbolinks:load', function(){

$(".alert").delay(2000).slideUp(500, function(){
      $(".alert").alert('close');
  });

//HERE I SHOULD ADD SOME CODE the solution in the wiki is coffescript I need a solution in js and how to add it here. });``

this is my form:

<div class="modal-content" id="modal_usuario"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×

</div> [<div] class="modal-body"> <%= simple_form_for(@usuario, html: {class: "miform form-horizontal"}, validate: true) do |f| %>

Nuevo Usuario

<%= f.error_notification %>

<%= f.label :usuario, class: "col-sm-4" %> <%= f.text_field :usuario, class: "col-sm-5" %>
<%= f.label :password, class: "col-sm-4" %> <%= f.password_field :password, class: "col-sm-5" %>
<%= f.label :password_confirmation, "Confirmar contraseña", class: "col-sm-4" %> <%= f.password_field :password_confirmation, class: "col-sm-5" %>

--- some extra code---

tagliala commented 6 years ago

Hi,

for normal forms, CSV should work out of the box.

Please provide all the information requested in the issue report template

Closing here, please start a new one and answer all the questions

mquispe1185 commented 6 years ago

HI, excuse me my english is bad, what do you refer to "out of the box"? which is the box in the form or modal?. thanks for reply

2018-01-12 6:58 GMT-03:00 Geremia Taglialatela notifications@github.com:

Hi,

for normal forms, CSV should work out of the box.

Please provide all the information requested in the issue report template

Closing here, please start a new one and answer all the questions

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/DavyJonesLocker/client_side_validations/issues/730#issuecomment-357194725, or mute the thread https://github.com/notifications/unsubscribe-auth/AZNy4bgVgNd2ffvrPczHAGDbOfGAmzQzks5tJyzdgaJpZM4Rbrzg .

-- Matias E. Quispe

tagliala commented 6 years ago

@mquispe1185 it should work without just by following the readme. You don't need extra javascript to make it work

mquispe1185 commented 6 years ago

yes, the gem works perfec in normal form, but not in modal, i add to my aplication.js this: $(document).on('turbolinks:load', function(){

 $('.modal').on('shown.bs.modal', function() {

$('form[data-client-side-validations]').enableClientSideValidations(); }); }); but csv is not working on modal. please help me. Also the issue could be in the way I call the modal. this is my link in the readme, there is no help for modal implementation

  • <%= link_to "New",new_usuario_url,{:remote => true, 'data-toggle' => "modal", 'data-target' => '#modal-window'} %>
  • 2018-01-12 11:35 GMT-03:00 Geremia Taglialatela notifications@github.com:

    @mquispe1185 https://github.com/mquispe1185 it should work without just by following the readme. You don't need extra javascript to make it work

    — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/DavyJonesLocker/client_side_validations/issues/730#issuecomment-357253885, or mute the thread https://github.com/notifications/unsubscribe-auth/AZNy4VXoDJKBQ8UR3hiQq_szZrEL8_e_ks5tJ22kgaJpZM4Rbrzg .

    -- Matias E. Quispe

    tagliala commented 6 years ago

    Hi, for modals you need to follow the wiki.

    Please use idempotent events as described here: https://github.com/DavyJonesLocker/client_side_validations/wiki/Bootstrap-Modal-Validations

    I've just added a javascript version of the coffee listener

    mquispe1185 commented 6 years ago

    I am using Turbolinks where should add ? this way is correct? $(document).on('turbolinks:load', function(){

    $(document).on('shown.bs.modal', '.modal', function() { $('form[data-client-side-validations]').enableClientSideValidations(); });

    }); });

    2018-01-12 13:34 GMT-03:00 Geremia Taglialatela notifications@github.com:

    Hi, for modals you need to follow the wiki.

    Please use idempotent events as described here: https://github.com/ DavyJonesLocker/client_side_validations/wiki/Bootstrap-Modal-Validations

    I've just added a javascript version of the coffee listener

    — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/DavyJonesLocker/client_side_validations/issues/730#issuecomment-357284351, or mute the thread https://github.com/notifications/unsubscribe-auth/AZNy4Vuu1iXOtopHaKh5m9i35WGe1rKiks5tJ4bugaJpZM4Rbrzg .

    -- Matias E. Quispe

    tagliala commented 6 years ago

    I am using Turbolinks where should add ? this way is correct?

    Nope.

    Idempotent events should not be wrapped inside $(document).on('turbolinks:load', function(){

    This is enough

    $(document).on('shown.bs.modal', '.modal', function() {
      $('form[data-client-side-validations]').enableClientSideValidations();
    });

    Please make sure that your modals have the .modal class and that this function is being called (put a breakpoint or an old fashioned console.log)