passing parameters to click function

passing parameters to click function

I updated my test page ( http://mckinley.no-ip.org:8080 ) to better illustrate my problem.

I'm trying to run through a loop and assign click events that require parameters from the outer function, but I can't figure out how to do that.

If you look at the log messages to the right, the text I write out shows what should be going into the stars' click events. But, if you click on the star, you'll see that, actually, they are all the same.

They all perform "doStars(2,6) "

The 2 and 6 are the maximum values of each of the two variables as they passed through their respective loops. The click events were set with references instead of values, and each pass through the loop changed all preceding passes.

How the heck do I do this?

I even tried adding the values using .data(), to no avail.

for(var star=1; star<6; star++) {
$("#vote"+filmId+star).data('filmId',filmId);
$("#vote"+filmId+star).data('star',star);
var outer = $(this);
$("#vote"+filmId+star).bind("click", {filmId:outer.data('filmId'), voteVal:outer.data('star')}, function(e, filmId, star){doStars(filmId,star);return false;});
}

Any help will be greatly appreciated.

Scott