Kamal G'ool Kamal G'ool - 1 month ago 17
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

jQuery
plugins, lets say Mask plugin, I get errors trying to
$('form').mask()
with error
c.off
is not a function,
I am willing to bet I am not being able to install the
js
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.

UPDATE:
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

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.

Thanks.