tags:

views:

307

answers:

4

Hi all,

Does anyone know why .hide("normal") does not seem to be working in jQuery 1.4.2? Is it a bug, has it been removed or am I just crazy? I've managed to duplicate this using several different scenarios. Just try this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml"&gt;
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"&gt;&lt;/script&gt;
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.0/jquery-ui.min.js"&gt;&lt;/script&gt;

<script type="text/javascript">
    $(document).ready(function() {
        $("button").click(function() {
             $("div.test").hide("normal");
        });
    });

</script>
</head>

<body>
    <div class="test">Hello this is a test</div>
    <button>Click</button>
</body>
</html>
+13  A: 

Problem is the class selector: .text != class="test"

I've done that well over 100 times, with the same words :)

Change to: $("div.test").hide("normal"); for a fix.


Update: It seems jQuery UI 1.8 is the issue, breaking "normal" as an animation speed.

This is from the jQuery UI forums:

Thanks for pointing that out. Normal was actually never a valid speed option, it was a myth from invalid documentation (used to exist in jQuery core docs as well). The only reason that it worked is because invalid values fall back to the default speed.

So it seems at least this member of the jQuery UI team doesn't think this is a breaking change, I strongly disagree and hope this is reversed in the next update.

Nick Craver
you are not only one! :)
confiq
sorry - understood false :) +1
ahmet2106
@ahmet2106 - Sorry, karim knows jQuery well so I was answering him directly...updated in case others find this :)
Nick Craver
@Nick Craver - here's the part that will drive you nuts. I fixed the className in the selector, result is the same :). Apologies for the borkage in the example, I will edit the question.
karim79
@karim79 - Works here with the fixed selector: http://jsfiddle.net/jS8Ye/
Nick Craver
@Nick Craver - jQuery UI 1.8.0 breaks "normal". Not cool. I must report this.
karim79
@karim79 - Ah you're right, let me see if I can find which changeset did this.
Nick Craver
A: 

Is "normal" even an option for the speed? I thought slow, fast and a time in milliseconds were the only options.

http://api.jquery.com/hide/

ScottE
"normal" is presently in some examples in the `show` documentation. Furthermore, I've been using it in several places in production for the past two years. I'm just trying to figure out whether I should just wait for a fix or do the necessary refactoring. This only became apparent when I decided to upgrade to the latest jQuery (from 1.4.1) and jQuery UI.
karim79
Why would you even use 'normal' in the first place?
ScottE
+6  A: 

Work's for me... you are wrapping:

$("button").click(function() {
     $("div.test").hide("normal");
});

in $(document).ready() aren't you?

Matt
Yes I am. I don't get it. There are at least six instances in my site where it is used, and none of them work. If I change to `hide("fast")` or `hide("slow")` it works just fine.
karim79
>.< What browser?
Matt
So far, Chrome, Safari and Firefox
karim79
@karim79 - Something's overriding the `.hide()` behavior then, have a link we can see?
Nick Craver
Works for me too. To get your example running, I did have to wrap it in a document.ready too.
Kieron
@Matt - thanks for the input. My hastily put together question failed to show that. I've edited the question. I will not do that again, but on the bright side, you've made 50 rep points :)
karim79
+3  A: 

Thank you for all the responses. In my question, I included what I thought was the relevant markup. However, unexpectedly and rather disturbingly, it is the inclusion of the latest jQuery UI (1.8.0) that is breaking "normal". Run the below, it will not work. Comment out the jQuery UI inclusion, and lo and behold, it will work!

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml"&gt;
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"&gt;&lt;/script&gt;
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.0/jquery-ui.min.js"&gt;&lt;/script&gt;

<script type="text/javascript">
    $(document).ready(function() {
        $("button").click(function() {
             $("div.test").hide("normal");
        });
    });

</script>
</head>

<body>
    <div class="test">Hello this is a test</div>
    <button>Click</button>
</body>
</html>
karim79
so UI was overwriting .hide? So it's Jquery bug? Did you report it?
confiq
I'm about to. This nearly caused me to break production :(
karim79
@karim79 - There are some open tickets on this, not responded to yet though: http://dev.jqueryui.com/ticket/5456
Nick Craver
@Nick - thanks for pointing that out, I had just registered, and was composing one. Now I won't bother.
karim79
@karim79 - According to the jQuery UI team: "Thanks for pointing that out. Normal was actually never a valid speed option, it was a myth from invalid documentation (used to exist in jQuery core docs as well). The only reason that it worked is because invalid values fall back to the default speed." Since it's worked forever I'd consider this a breaking change, but the guy who broke it doesn't seem to think so.
Nick Craver
@Nick, What! But "normal" actually exists in *many, many* examples throughout the docs! That's a legendary screw-up on their part. I guess I'll have to refactor "normal" out of everything.
karim79
@karim79 - I hope they reverse this...jQuery UI breaking what works in jQuery core in unacceptable, regardless of what "should" be allowed. I guess you can just replace `.hide("normal")` with `.slideUp()`, but you *definitely* shouldn't have to.
Nick Craver
@Nick - thanks for all the input. Can you somehow incorporate the info from your comments into your answer, so I can tick it off as correct - considering how this post has evolved.
karim79
@karim79 - Updated as requested, hopefully helps the next person finding this same issue.
Nick Craver