Skip to content

Commit 44994e6

Browse files
committed
fix #nav_main click handler's wrong behavior on mobile
In the event handler, 'this' is not a jquery object, but a DOM object. Instead of using $(this) to fix this problem, $mainNav is used because it is already created and no need to be re-wrapped as jquery object. $varname style is used for preventing this type of problem.
1 parent cc5984d commit 44994e6

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

site/javascript/garden.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ function Page() {
143143
Page.prototype = {
144144
init: function() {
145145
var that = this,
146-
mainNav = $('#nav_main');
146+
$mainNav = $('#nav_main');
147147

148148
$.extend(this, {
149149
scrollLast: 0,
@@ -177,14 +177,14 @@ Page.prototype = {
177177
// Show menu for tablets
178178
$('#show_menu').click(function (){
179179
var scrollTop = $.mobile ? that.window.scrollTop() : 0;
180-
181-
mainNav.slideDown(300).css('top', scrollTop);
180+
181+
$mainNav.slideDown(300).css('top', scrollTop);
182182
return false;
183183
});
184-
185-
$('#nav_main').click(function(){
184+
185+
$mainNav.click(function(){
186186
if(that.window.width() < 1000)
187-
mainNav.slideUp(300, function() {this.removeAttr('style');});
187+
$mainNav.slideUp(300, function() { $mainNav.removeAttr('style'); });
188188
});
189189
},
190190

0 commit comments

Comments
 (0)