Skip to content
This repository has been archived by the owner on Jun 14, 2020. It is now read-only.

Commit

Permalink
Ensure we bind events object events in assignEvents using _.bind, so …
Browse files Browse the repository at this point in the history
…they don't disppaer when unassignEvents is called
  • Loading branch information
Craga89 committed Jul 17, 2013
1 parent 645aa4e commit fdd2fdd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
8 changes: 0 additions & 8 deletions src/core/class.js
Expand Up @@ -102,14 +102,6 @@ PROTOTYPE.render = function(show) {
// Setup widget classes
this._setWidget();

// Assign passed event callbacks (before plugins!)
$.each(options.events, function(name, callback) {
$.isFunction(callback) && tooltip.bind(
(name === 'toggle' ? ['tooltipshow','tooltiphide'] : ['tooltip'+name])
.join(namespace)+namespace, callback
);
});

// Initialize 'render' plugins
$.each(PLUGINS, function(name) {
var instance;
Expand Down
8 changes: 7 additions & 1 deletion src/core/events.js
Expand Up @@ -145,7 +145,8 @@ PROTOTYPE._trigger = function(type, args, event) {

// Event assignment method
PROTOTYPE._assignEvents = function() {
var options = this.options,
var self = this,
options = this.options,
posOptions = options.position,

tooltip = this.tooltip,
Expand All @@ -161,6 +162,11 @@ PROTOTYPE._assignEvents = function() {
hideEvents = options.hide.event ? $.trim('' + options.hide.event).split(' ') : [],
toggleEvents = [];

// Assign passed event callbacks
$.each(options.events, function(name, callback) {
self._bind(tooltip, name === 'toggle' ? ['tooltipshow','tooltiphide'] : ['tooltip'+name], callback);
});

// Hide tooltips when leaving current window/frame (but not select/option elements)
if(/mouse(out|leave)/i.test(options.hide.event) && options.hide.leave === 'window') {
this._bind(documentTarget, ['mouseout', 'blur'], function(event) {
Expand Down

0 comments on commit fdd2fdd

Please sign in to comment.