Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing ClientSideValidations gem inside ajax rendered partial
    primarykey
    data
    text
    <p>I am currently using the ClientSideValidations gem and stuck while rendering a partial using ajax and trying to validate addresses inside that rendered partial with the gem mentioned above. Nothing happens when entering a wrong combination specified in the model.</p> <p>If browsing to the address-form directly and trying out validations, everything works fine, just like specified.</p> <p>Any hints or thoughts on how to make the validations gonna work inside the partial?</p> <p>Thanks!</p> <p><strong>EDIT</strong>: No errors in JS console, just nothing happens when for example entering a too short zipcode (specified in the model with 5 digits). Btw I use haml for the views.</p> <p><strong>So the code in my view:</strong></p> <pre><code> = link_to "Shipping", addresses_path, :remote =&gt; true </code></pre> <p><strong>corresponding controller addresses_controller.rb</strong></p> <pre><code>respond_to do |format| ... format.js {render :layout =&gt; false} ... end </code></pre> <p><strong>corresponding index.js.erb</strong></p> <pre><code>$("#ajax_content").html("&lt;%= escape_javascript(render :partial =&gt; "partialXY") %&gt;"); </code></pre> <p><strong>and corresponding partial</strong></p> <pre><code> = form_for @address, :validate =&gt; true, :id =&gt; "address_form", :remote =&gt; true do |f| - if @address.errors.any? #error_explanation %h2 = pluralize(@address.errors.count, "error") prohibited this user from being saved: %ul - @address.errors.full_messages.each do |msg| %li =msg %ul %li = f.label :type = f.select :address_type, [['Billing Address', 'billing'],['Shipping Address', 'shipping']], :class =&gt; "address_selection" %li = f.label :gender = f.select :gender, [['Male', 'male'],['Female', 'female']], :class =&gt; "text_field" %li = f.label :last_name = f.text_field :last_name, :id =&gt; "last_name", :class =&gt; "text_field" %li = f.label :first_name = f.text_field :first_name, :class =&gt; "text_field" %li = f.label :company_name = f.text_field :company_name, :class =&gt; "text_field" %li = f.label :street = f.text_field :street, :class =&gt; "text_field" %li = f.label :number = f.text_field :number, :class =&gt; "text_field" %li = f.label :zipcode = f.text_field :zipcode, :class =&gt; "text_field" %li = f.label :place = f.text_field :place, :class =&gt; "text_field" %li = f.label :phone_no = f.text_field :phone_no, :class =&gt; "text_field" %li = f.label :country = f.text_field :country, :class =&gt; "text_field" %li = f.label :email = f.text_field :email, :class =&gt; "text_field" %li = f.submit </code></pre> <p>so like I said nothing happens when validating the rendered partial inputs like zipcode, etc. The funny thing is, that if you look at the following, automatically by rails generated view for editing addresses, the validation works just fine.</p> <p><strong>rails generated view to edit address</strong></p> <pre><code>=render 'partialXY' </code></pre> <p>I have been working on this issue for a long time and have absolutely no clue on how to fix this. I'm sure it has something to do with ajax since using validation when rendering the rails generated partial works just fine.</p> <p>Thanks a lot! Phil</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload