diff --git a/src/definitions/modules/rating.js b/src/definitions/modules/rating.js index a4842d775..db8be05b8 100644 --- a/src/definitions/modules/rating.js +++ b/src/definitions/modules/rating.js @@ -87,12 +87,10 @@ $.fn.rating = function(parameters) { destroy: function() { module.verbose('Destroying previous instance', instance); + module.remove.events(); $module .removeData(moduleNamespace) ; - $icon - .off(eventNamespace) - ; }, refresh: function() { @@ -169,13 +167,29 @@ $.fn.rating = function(parameters) { return currentRating; }, + bind: { + events: function() { + module.verbose('Binding events'); + $module + .on('mouseenter' + eventNamespace, selector.icon, module.event.mouseenter) + .on('mouseleave' + eventNamespace, selector.icon, module.event.mouseleave) + .on('click' + eventNamespace, selector.icon, module.event.click) + ; + } + }, + + remove: { + events: function() { + module.verbose('Removing events'); + $module + .off(eventNamespace) + ; + } + }, + enable: function() { module.debug('Setting rating to interactive mode'); - $icon - .on('mouseenter' + eventNamespace, module.event.mouseenter) - .on('mouseleave' + eventNamespace, module.event.mouseleave) - .on('click' + eventNamespace, module.event.click) - ; + module.bind.events(); $module .removeClass(className.disabled) ; @@ -183,9 +197,7 @@ $.fn.rating = function(parameters) { disable: function() { module.debug('Setting rating to read-only mode'); - $icon - .off(eventNamespace) - ; + module.remove.events(); $module .addClass(className.disabled) ;