dreyescat / bootstrap-rating

Bootstrap Rating is a jQuery plugin that creates a rating control that uses Bootstrap glyphicons for rating symbols.
http://dreyescat.github.io/bootstrap-rating/
MIT License
192 stars 78 forks source link

Not working on Ruby on Rails project. #25

Closed ZSeba closed 8 years ago

ZSeba commented 8 years ago

Hey there!

First of all, thank you for making this. Of all the plugins I could find, this one seems the most useful for my purposes.

I'm having a little trouble running this RoR.

I've imported four files into my project. "bootstrap-ratings" ,"bootstrap-ratings.min" and "Gruntfile" javascripts in my application.js file, and "bootstrap-rating.css into mi application.scss file.

application.js //= require jquery //= require jquery_ujs //= require turbolinks //= require_tree . //= require bootstrap-sprockets //= require bootstrap.min //= require bootstrap-rating //= require bootstrap-rating.min

aplication.scss @import "bootstrap"; @import "bootstrap.min"; @import "bootstrap-rating"; When I use in my view, it looks fine, but if I try to use $('input').rating(2);for example (setting the rating to default to 2) in my reviews.coffee file ('Reviews' is the controller I'm using in this project) I get the following error.

Uncaught TypeError: $(...).rating is not a function

Also, if I try to attach an event, like in the example:

$('input').on('change', function () {
  alert('Rating: ' + $(this).val());
});

I'm getting SyntaxError: [stdin]:5:25: reserved word "function"

What am I doing wrong? Any help is greatly appreciated.

dreyescat commented 8 years ago

Hi @ZSeba! I don't know RoR very well... but, from a JavaScript perspective, I can point you to some possible causes of this error:

Uncaught TypeError: $(...).rating is not a function

This could be caused because:

Maybe someone else could help you out or you can try to ask in Stackoverflow.

Hope it helps!

ZSeba commented 8 years ago

Hey, @dreyescat

Thank you for your answer. I figured what I got wrong. I was using the Rails assets pipeline wrong. Now the plugin is working perfectly on my app! :smile:

dreyescat commented 8 years ago

Glad you managed to make it work 👍 .

I close the issue as resolved.