Note that there are some explanatory texts on larger screens.

plurals
  1. POAjax for email validation in rails
    primarykey
    data
    text
    <p>I want to use jquery-rails to check if a email exists in my database. But I can't get jquery set up right into my rails application. My form looks like this :</p> <pre><code>&lt;%= form_for @user, :html =&gt; {:class =&gt; "col-md-10 center-margin"} do |f| %&gt; &lt;div class="form-row"&gt; &lt;div class="form-label col-md-2"&gt; &lt;label for=""&gt; Email: &lt;span class="required"&gt;*&lt;/span&gt; &lt;/label&gt; &lt;/div&gt; &lt;div class="form-input col-md-10"&gt; &lt;%= f.text_field :email, type: 'text', data: {trigger: "change"}, data: {required: "true" }, class: "parsley-validated", id: "user_email" %&gt; &lt;/div&gt; &lt;/div&gt; &lt;%= f.submit %&gt; &lt;/div&gt; &lt;% end %&gt; </code></pre> <p>In my application.js I have the following code:</p> <pre><code>$("#user_email").change(function(){ $("#user_email").append("&lt;p&gt;Test&lt;/p&gt;"); }); </code></pre> <p>When I start typing in the email field I would think test gets appended but nothing happens. What am I doing wrong?</p> <p>in my application.html.erb I have :</p> <pre><code>&lt;%= javascript_include_tag "application" %&gt; &lt;%= javascript_include_tag "jquery-rails.js" %&gt; </code></pre> <p>Edit:</p> <p>This is how my application.js looks like </p> <pre><code>// This is a manifest file that'll be compiled into application.js, which will include all the files // listed below. // // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. // // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the // compiled file. // // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details // about supported directives. // //= require jquery //= require jquery_ujs //= require turbolinks //= require_tree . //= require bootstrap $( document ).ready(function() { $("#user_email").change(function(){ var currentVal = $("#user_email").val(); $("#user_email").val(currentVal + " Test"); }); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
    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