Reputation: 4003
I have a problem with event.stopPropagation (), in my code: (! When put. Show () after this event works perfectly, however, as put. SlideUp () does not work! What I truly want is when the user click the search bar and the same body and the chat is hidden, it must appear with the effect slideUp (), If I remove the stopPropagation, clicking in the search bar of your body chat also disappear as this within the event of the div.
See jsfiddle Here
$(".chatHeader").on('click', function() {
$('.chatBody').slideToggle();
});
$('#searchText').click(function(e) {
event.stopPropagation();
$('.chatBody').show();
// $('.chatBody').slideUp(); not works
});
Who can help me with this, I would be very grateful for your time invested on it!
Thank you!
Upvotes: 0
Views: 281
Reputation: 33880
This one is tricky. Read that :
"Hide the matched elements with a sliding motion."
This is taken from the jquery doc of slideUp: http://api.jquery.com/slideUp/
In other word, you need to use slideDown()
if you want the window to show.
"Display the matched elements with a sliding motion."
http://api.jquery.com/slideDown/
Upvotes: 1
Reputation: 2463
try
$(".chatHeader").not('#searchText').on('click', function() { ...
ive seen a conflict between slideUp and slideToggle
Upvotes: 0
Reputation: 13742
is there any specific reason you use event.stopPropagation() ? that would block the event from bubbling up.. Try event.preventDefault();
Upvotes: 0