Giter Club home page Giter Club logo

jquery.rating's Introduction

jquery.rating

Turns a select input element into a rating control.

An easy to use rating control. It takes a normal select box, and turns it into a rating that your users can click on. The select box is preserved so you can still bind on change, get, and set the value in the rating control. The image is controlled with CSS and a simple gif, so you can make it look like anything you need.

<select class="rating">
    <option value="0">Did not like</option>
    <option value="1">Ok</option>
    <option value="2" selected="selected">Liked</option>
    <option value="3">Loved!</option>
</select>

$(".rating").rating();

The select box is now replaced with the rating control. Each option you put in the select box is turned into a star, so you can easily have as many stars as you want. The value you set is the value that is returned for the selected star. The text becomes the title on the star.

You can turn the cancel button on and off, and change the value of the cancel button by passing it when you create the rating control. $(".rating").rating({showCancel: true, cancelValue: null,})

Available Options:

  • showCancel: true : Should the cancel button be shown?
  • cancelValue: null : If cancel button is shown, what should it's value be?
  • startValue: null : If no property has the 'selected' attribute, what value should be displayed?
  • cancelTitle: "Cancel" : The title for the cancel button.

jquery.rating's People

Contributors

dovy avatar krik avatar montrezorro avatar pilaf avatar raags avatar ripter avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jquery.rating's Issues

Cancel title for other languages

Hi,
I think that it is important to have a property such as cancelTitle in-which the English word Cancel may be replaced by any other word such as Quit, Annuleren, Annulla, Annuler, Abbrechen, إلغاء, etc

So we can do:
$(".rating").rating({showCancel: true, cancelValue: null, cancelTitle: 'Annuler'})

First star selected by default

The first star is selected even when there is no rating yet.

This is due to the fact that the first <option> of my <select> element is set as selected when no one else is.
Even if there is no selected="selected" parameter in the element, I can see that with the inspector (firebug). So does jQuery see this element as selected.

I don't know why you don't have the problem and how to avoid it... Thanks!

isDirty

Hello there.
I am using this cool plugin in a Rails application and it's giving me an error when I click on a star, the error is

Uncaught ReferenceError: isDirty is not defined

Plus I had to change some line of code to make it work with Rails select helper generated code. I don't know if I am missing something or if my mod is really useful. I'd like to discuss it with you, but because you haven't provided an email I write you here :)

Duplicate ratings created if called multiple times

I know it sounds like this is probably a feature and not a bug, but i have a heavily-ajaxy form that shows and hides panels and needs to call .rating() each time. when it does that, you end up with several rating controls for 1 select box. I edited the source in my app to add one line to remove it, but i'm not 100% sure this is foolproof, so i thought I'd let you know and you could see if it was worth adding in a future version.

in the section at the bottom where you "process the matched elements," i made the following edit:

        //We only do select types
        if ($(this).attr("type") !== "select-one") { return; }
        //Save 'this' for ease of development
        var selectBox = this;

        // custom code to stop duplicate creation
        if ($(selectBox).siblings("div").length > 0) return false;
        // end custom code

        //Hide the selectBox
        $(selectBox).css("display", "none");
        ...

onchange event is not being fired

Clicking on stars doesnt fire onchange event that is bound to the select box.
Tried the included default.html ("Bind $.serialize() On Change") example on all Chrome, FF and IE and it doesn't work.

Uncaught ReferenceError: isDirty is not defined
Line 104

jquery 1.6.1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.