1

I have got a script here that animates a div changing height, then after a label should appear. Under that I have return false so the next page doesn't load.

It works when it is like this

$("label#error-username_r").show();
return false;

However when I set the duration it ignores it, and ignores the return false and loads the next page like this:

$("label#error-username_r").show("fast");
return false;

Here is all of the code:

        $("div#cover").animate
            ({
                height: window.innerHeight*0.8
                }, {queue:false, duration:300, easing:"backEaseInOut"}
            );
        $("div#cover-bottom").animate
            ({
                height: window.innerHeight*0.2
                }, {queue:false, duration:300, easing:"backEaseInOut"}
            );
        $("label#error-username_r").show();
        return false;
Peter Stuart
  • 2,362
  • 7
  • 42
  • 73
  • 1
    FYI, there is no need to put the tag name in front of the id. That just slows down selector engines. `"label#error-username_r"` can just be `"#error-username_r"` and so on. – jfriend00 Nov 11 '11 at 01:15
  • There must be something in your code that you aren't showing us because `.show("fast")` works just fine when used properly. You can see it work here: http://jsfiddle.net/jfriend00/V6DYz/ – jfriend00 Nov 11 '11 at 01:18
  • It was working fine until I added the ease plugin from the jQuery website. When I remove the ease settings in my .animate it works fine again? – Peter Stuart Nov 11 '11 at 01:25
  • could be the conflicts with native jquery code when introducing 3rd jquery plugin. Perhaps try to reorder your jquery code, say include them before `

    `. It's not always necessary to have them within the header.

    – woodykiddy Nov 11 '11 at 01:49
  • @PeterStuart - To close off this question, you should post an answer yourself that explains that it was some sort of error/conflict with a jQuery easing plug-in. Then give your own answer the green checkmark. – jfriend00 Nov 11 '11 at 01:51

2 Answers2

1

I've noticed similar behavior myself on occasion. I started putting my values in as:

$("#error-username_r").show(200);

This always works for me.

Jeremy Holovacs
  • 22,480
  • 33
  • 117
  • 254
1

It's kinda hard to dig out the real problem without HTML. And I don't think it's because show("fast") failed here. It's gotta be some other code that behaved incorrectly.

You might want to try the duration as the passing parameter, like this

("#error-username_r").show(1000);

But I doubt that would really solve your problem either, as I said earlier, the error most likely is in somewhere else of your code.

Anyway, I'd suggest you try Firebug or any other web development tools to inspect the js errors and see what the error messages are.

woodykiddy
  • 6,074
  • 16
  • 59
  • 100
  • Hi there. I already use firebug. I have actually came accross various errors now. Firebug is shotting out errors with this easing plugin so I'm going to remove it and find an alternative. Thanks :) – Peter Stuart Nov 11 '11 at 01:44
  • 1
    I've added a comment under your question. I was suggesting that you could try re-organize your jquery code. See if you could solve it by not removing easing plugin. Worth a try. – woodykiddy Nov 11 '11 at 01:52
  • I had the same problem. http://stackoverflow.com/questions/3428766/jquery-show-for-5-seconds-then-hide helped me. – Maximosaic Dec 17 '13 at 09:59