Skip to content

Commit 16dbc05

Browse files
author
Ben Kamens
committed
Make menu-aim work when jQuery collection contains multiple elements
1 parent b414bdc commit 16dbc05

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

jquery.menu-aim.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,17 @@
6666
* https://github.com/kamens/jQuery-menu-aim
6767
*/
6868
(function($) {
69+
6970
$.fn.menuAim = function(opts) {
71+
// Initialize menu-aim for all elements in jQuery collection
72+
this.each(function() {
73+
init.call(this, opts);
74+
});
75+
76+
return this;
77+
};
7078

79+
function init(opts) {
7180
var $menu = $(this),
7281
activeRow = null,
7382
mouseLocs = [],
@@ -248,18 +257,13 @@
248257
/**
249258
* Hook up initial menu events
250259
*/
251-
var init = function() {
252-
$menu
253-
.mouseleave(mouseleaveMenu)
254-
.find(options.rowSelector)
255-
.mouseenter(mouseenterRow)
256-
.mouseleave(mouseleaveRow);
257-
258-
$(document).mousemove(mousemoveDocument);
259-
};
260+
$menu
261+
.mouseleave(mouseleaveMenu)
262+
.find(options.rowSelector)
263+
.mouseenter(mouseenterRow)
264+
.mouseleave(mouseleaveRow);
265+
$(document).mousemove(mousemoveDocument);
260266

261-
init();
262-
return this;
263267
};
264268
})(jQuery);
265269

0 commit comments

Comments
 (0)