[jQuery] Re: get visibility state after toggle()

2009-02-10 Thread Paul Mills

Hi,
You don't need to run the video - try this link instead
http://jsbin.com/ojuju

There are two snippets of Javsscript code in the page that is shown:
The first uses uses a class to control the hide/show.
The second uses $( selector ).is(':visible') to test if the text is
visible.

Paul



[jQuery] Re: get visibility state after toggle()

2009-02-10 Thread brian

$( selector ).is(':visible') -- this is precisely what I was looking
for. How did I forget that?

Thanks a bunch!

On Tue, Feb 10, 2009 at 2:51 PM, Paul Mills paul.f.mi...@gmail.com wrote:

 Hi,
 You don't need to run the video - try this link instead
 http://jsbin.com/ojuju

 There are two snippets of Javsscript code in the page that is shown:
 The first uses uses a class to control the hide/show.
 The second uses $( selector ).is(':visible') to test if the text is
 visible.

 Paul




[jQuery] Re: get visibility state after toggle()

2009-02-09 Thread Paul Mills

Brian
Here are a couple of demos that might help.
   http://jsbin.com/ojuju/edit

Paul

On Feb 9, 4:01 am, brian bally.z...@gmail.com wrote:
 How can I tell what the visibility state of an element is which has
 just been toggled? Is my selector no good or is it a matter of timing?

 . The situation is that I'm displaying a page of search results. I'd
 like the advanced search features to be present at the top but I'd
 prefer to hide them. So, I'm creating a link which will toggle the box
 display. What I haven't been able to figure out is how to swap the
 text of the link depending upon the state of the box. Or, rather, it
 will change to hide form the first time the box is displayed but
 remains that way ever after.

 Here's the code I'm working with:

 $(function() {
         $('#advanced_search').hide().after('a href=#
 id=toggle_formrefine search/a');

         $('#toggle_form').css('float', 'right').click(function(e)
         {
                 e.preventDefault();
                 $('#advanced_search').toggle('fast');
                 $(this).text($('#advanced_search:visible').length ? 'hide 
 form' :
 'refine search');
         });

 });

 I also tried:

         $('#toggle_form').css('float', 'right').click(function(e)
         {
                 e.preventDefault();
                 var search = $('#advanced_search');

                 search.toggle('fast');
                 $(this).text(search.css('display') == 'block' ? 'hide form' :
 'refine search');
         });


[jQuery] Re: get visibility state after toggle()

2009-02-09 Thread brian

The video won't play for me :-( tthanks anyway. FF3.0.6 on linux

So ... do you happen to know the answer to my query, by any chance?

On Mon, Feb 9, 2009 at 8:08 AM, Paul Mills paul.f.mi...@gmail.com wrote:

 Brian
 Here are a couple of demos that might help.
   http://jsbin.com/ojuju/edit

 Paul

 On Feb 9, 4:01 am, brian bally.z...@gmail.com wrote:
 How can I tell what the visibility state of an element is which has
 just been toggled? Is my selector no good or is it a matter of timing?

 . The situation is that I'm displaying a page of search results. I'd
 like the advanced search features to be present at the top but I'd
 prefer to hide them. So, I'm creating a link which will toggle the box
 display. What I haven't been able to figure out is how to swap the
 text of the link depending upon the state of the box. Or, rather, it
 will change to hide form the first time the box is displayed but
 remains that way ever after.

 Here's the code I'm working with:

 $(function() {
 $('#advanced_search').hide().after('a href=#
 id=toggle_formrefine search/a');

 $('#toggle_form').css('float', 'right').click(function(e)
 {
 e.preventDefault();
 $('#advanced_search').toggle('fast');
 $(this).text($('#advanced_search:visible').length ? 'hide 
 form' :
 'refine search');
 });

 });

 I also tried:

 $('#toggle_form').css('float', 'right').click(function(e)
 {
 e.preventDefault();
 var search = $('#advanced_search');

 search.toggle('fast');
 $(this).text(search.css('display') == 'block' ? 'hide form' :
 'refine search');
 });