This has the 2 added benefits. Firstly, it doesn’t require you to nest all your handlers into a function that then needs to be called both on document ready and page:load. Secondly, you now only have 1 callback function created for the life of the session that handles the span.star click event.
Comments
Although the author’s solution does solve the problem, a cleaner approach would be something like:
jQuery -> $(document).on "click", "span.star", -> ... code dealing with ratings ...
This has the 2 added benefits. Firstly, it doesn’t require you to nest all your handlers into a function that then needs to be called both on document ready and page:load. Secondly, you now only have 1 callback function created for the life of the session that handles the span.star click event.
Post a comment