April 16, 2012

jquery div slider when postback div close

Question by saadan

I have a jquery slider that open and close my div. but when the page get a postback the div is closed.
and i want the div to stay open.

my slider

 if ($(".div").is(":hidden")) {
            $(".div").slideDown(1000); // slide it down

        } else {
            $(".div").slideUp(1000); // hide it
        }

I thought about change the address, such as

website.com#open

and then check the adress
but how can i do this ?

Answer by Starx

When the page postbacks, the markup reverts to the original state. So, $(".div").is(":hidden") will always return true.

You can create some sort of state identifier and use that to check the state.

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!