Created
October 15, 2010 11:07
-
-
Save olleolleolle/628017 to your computer and use it in GitHub Desktop.
Makes the onclick handler have a "this" that is the useful star element.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/js/jquery.raty.js b/js/jquery.raty.js | |
index cefc128..7b09b81 100755 | |
--- a/js/jquery.raty.js | |
+++ b/js/jquery.raty.js | |
@@ -140,7 +140,7 @@ | |
.live('click', function() { | |
$('input#' + containerId + '-score').val(0); | |
if (onClick) { | |
- onClick(0); | |
+ onClick.apply($this, [0]); | |
} | |
}); | |
} else { | |
@@ -162,7 +162,7 @@ | |
.live('click', function() { | |
$('input#' + containerId + '-score').val(this.alt); | |
if (onClick) { | |
- onClick(this.alt); | |
+ onClick.apply($this, [this.alt]); | |
} | |
}); | |
@@ -241,7 +241,7 @@ | |
var star = (score >= options.number) ? options.number : score; | |
initialize(star); | |
if (options.onClick) { | |
- options.onClick(star); | |
+ options.onClick.apply($this, [star]); | |
} else { | |
debug('You should add the "onClick: function() {}" option.'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Jonsson,
I didn't know about the "apply", it's cool.
Feel free to other contributions, I would be very happy.
Thank you. (: