Created
August 19, 2010 02:10
-
-
Save scottmessinger/536797 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('.editable').live('mouseover mouseout', function(event) { | |
if (event.type == 'mouseover') { | |
function() { | |
$(this).children('.nubbin_wrapper').show(); | |
} | |
} else { | |
function() { | |
$(this).children('.nubbin_wrapper').hide(); | |
} | |
} | |
}); |
You're right, it should be show() on line 4.
I'm getting the following error:
Uncaught SyntaxError: Unexpected token ( on line 3.
I took out the function() on line 4 and 8 and it worked. Thanks!
Yeah no reason to define a fn there. Just do it.
I had a typo above, I meant why check the event type if both paths are the same. But I see you are trying to toggle a div. You can actually bind "hover" to more than just links with jQuery, and toggle()
can replace hide() and show(), this might be a more compact way to accomplish the same:
$('.editable').hover(function() { $(this).children('.nubbin_wrapper').toggle() });
Originally, I did use hover, but I was reloading a div with ajax and thus needed to use .live(). Live doesn't work with hover--you have to use the two mouse events.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You should be able to put line 8 in the else condition without wrapping it in a function. Since both code paths are the same, why the event type is mouseover? Is one of those supposed to be show() instead of hide()?