Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Uncaught TypeError: ...mask is not a function] Rails 6.1 setup #3

Open
luisampuerov opened this issue Dec 6, 2021 · 1 comment
Open

Comments

@luisampuerov
Copy link

Hello,

I'm using your gem on my ruby on rails project. Ruby: 2.6.8, Rails: 6.1.4.1. When I follow the steps in your README I cannot make use of the masks.

Can you please let me know how put the require in the application.js file?: this line: //= require jquery.mask. I think that is a comment one, but if I decomment I get an error, what is the correct format?

When I try to use $('#my_id').mask('999.999.999-99' ) in my javascript I get in the console: Uncaught TypeError: $(...).mask is not a function.

Thanks in advance. Regards

@rannyeribatista
Copy link

I had the same issue. I was able to solve the problem by removing a duplicate jQuery call I had in my application.html.haml layout file. Then, I included jQuery in my application.js before the jquery.mask require line. Your application.js file would look like this:

//= require rails-ujs
//= require jquery
//= require jquery.mask

Make sure you're not importing any other versions of jquery that could be conflicting and you're good to go :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants