Kamal G'ool Kamal G'ool - 1 year ago 133
jQuery Question

Adding jQuery plugins to my rails 4 apps

It seems to be that I'm missing something, I am not being able to add

plugins, lets say Mask plugin, I get errors trying to
with error
is not a function,
I am willing to bet I am not being able to install the
files in the right place, I am using rails 4, what am I missing ?

also when I include them remotely in the

# application.erb
<%= javascript_include_tag https://cdn.jsdelivr.net/jquery.mask/1.13.9/jquery.mask.min.js" %>

I still get errors, not only with that specific plugin.

I installed jquery.mask.min.js to vendor/assets/javascripts

enter image description here

I //= require jquery.mask.min.js in application.js

//= require jquery
//= require jquery_ujs
//= require jquery.mask.min.js

I try to $('input').mask('99-999-99');

I get error saying mask is not a function

enter image description here

Answer Source

Okay, my bad, The problem was because of both requirng including jquery

once //= require at the application.js

and once <%= javascript_include_tag "http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.6.4.min.js" %>

from the application layout.


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download