|
76 | 76 | this.open = false; |
77 | 77 | this.$trigger = this.$el.children( '.dl-trigger' ); |
78 | 78 | this.$menu = this.$el.children( 'ul.dl-menu' ); |
79 | | - this.$menuitems = this.$menu.find( 'li:not(.dl-back)' ); |
| 79 | + this.$menu.hide(); |
| 80 | + this.$el.css('z-index', '9999'); |
80 | 81 | this.$el.find( 'ul.dl-submenu' ).prepend( '<li class="dl-back"><a href="#">' + this.options.backLabel + '</a></li>' ); |
81 | | - this.$back = this.$menu.find( 'li.dl-back' ); |
82 | 82 |
|
83 | 83 | // Set the label text for the back link. |
84 | 84 | if (this.options.useActiveItemAsBackLabel) { |
85 | | - this.$back.each(function() { |
| 85 | + this.$menu.find( 'li.dl-back' ).each(function() { |
86 | 86 | var $this = $(this), |
87 | 87 | parentLabel = $this.parents('li:first').find('a:first').text(); |
88 | 88 |
|
|
113 | 113 | $body.off( 'click' ).children().on( 'click.dlmenu', function() { |
114 | 114 | self._closeMenu() ; |
115 | 115 | } ); |
116 | | - |
117 | 116 | } |
118 | 117 | return false; |
119 | 118 | } ); |
120 | 119 |
|
121 | | - this.$menuitems.on( 'click.dlmenu', function( event ) { |
| 120 | + this.$menu.on( 'click.dlmenu', 'li:not(.dl-back)', function( event ) { |
122 | 121 |
|
123 | 122 | event.stopPropagation(); |
124 | 123 |
|
|
158 | 157 |
|
159 | 158 | } ); |
160 | 159 |
|
161 | | - this.$back.on( 'click.dlmenu', function( event ) { |
| 160 | + this.$menu.on( 'click.dlmenu', 'li.dl-back', function( event ) { |
162 | 161 |
|
163 | 162 | var $this = $( this ), |
164 | 163 | $submenu = $this.parents( 'ul.dl-submenu:first' ), |
|
219 | 218 | else { |
220 | 219 | onTransitionEndFn.call(); |
221 | 220 | } |
| 221 | + this.$menu.hide(); |
222 | 222 |
|
223 | 223 | this.open = false; |
224 | 224 | }, |
|
229 | 229 | }, |
230 | 230 | _openMenu : function() { |
231 | 231 | var self = this; |
| 232 | + |
| 233 | + this.$menu.show(); |
| 234 | + |
232 | 235 | // clicking somewhere else makes the menu close |
233 | 236 | $body.off( 'click' ).on( 'click.dlmenu', function() { |
234 | 237 | self._closeMenu() ; |
|
242 | 245 | // resets the menu to its original state (first level of options) |
243 | 246 | _resetMenu : function() { |
244 | 247 | this.$menu.removeClass( 'dl-subview' ); |
245 | | - this.$menuitems.removeClass( 'dl-subview dl-subviewopen' ); |
| 248 | + this.$menu.find( 'li:not(.dl-back)' ).removeClass( 'dl-subview dl-subviewopen' ); |
246 | 249 | } |
247 | 250 | }; |
248 | 251 |
|
|
0 commit comments