[jQuery] Re: Toggling an objects visiblty without show and hide

2007-07-25 Thread Stephan Beal
On Jul 25, 12:41 am, Mitchell Waite [EMAIL PROTECTED] wrote: I know this is trivial but what it turned out I needed was something this simple jQuery.fn.toggleVis = function() { if(chesireCat.style.visibility == 'hidden') { chesireCat.style.visibility = 'visible';

[jQuery] Re: Toggling an objects visiblty without show and hide

2007-07-25 Thread Ganeshji Marwaha
jQuery.fn.toggleVis = function() { if(this.style.visibility == 'hidden') { this.style.visibility = 'visible'; } else { this.style.visibility = 'hidden'; } }; doesn't this here refer to the jquery object... I don't think jquery object has a style

[jQuery] Re: Toggling an objects visiblty without show and hide

2007-07-25 Thread Rob Desbois
Ganeshji, Correct, As Aaron states above, 'this' refers to the jQuery object, hence this code will not work. Mitch, As I can see it I think you're misunderstanding how jQuery works from the outside at quite a fundamental level. Did you run through the tutorials at

[jQuery] Re: Toggling an objects visiblty without show and hide

2007-07-25 Thread Mitchell Waite
Take a look at the code examples and tell me if I am missing something here. Mitch -Original Message- From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Stephan Beal Sent: Tuesday, July 24, 2007 11:31 PM To: jQuery (English) Subject: [jQuery] Re: Toggling an objects

[jQuery] Re: Toggling an objects visiblty without show and hide

2007-07-25 Thread Mitchell Waite
an objects visiblty without show and hide Ganeshji, Correct, As Aaron states above, 'this' refers to the jQuery object, hence this code will not work. Mitch, As I can see it I think you're misunderstanding how jQuery works from the outside at quite a fundamental level. Did you run through the tutorials

[jQuery] Re: Toggling an objects visiblty without show and hide

2007-07-25 Thread Rob Desbois
] On Behalf Of Stephan Beal Sent: Tuesday, July 24, 2007 11:31 PM To: jQuery (English) Subject: [jQuery] Re: Toggling an objects visiblty without show and hide On Jul 25, 12:41 am, Mitchell Waite [EMAIL PROTECTED] wrote: I know this is trivial but what it turned out I needed was something this simple

[jQuery] Re: Toggling an objects visiblty without show and hide

2007-07-25 Thread Rob Desbois
*From:* jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] *On Behalf Of *Rob Desbois *Sent:* Wednesday, July 25, 2007 2:14 AM *To:* jquery-en@googlegroups.com *Subject:* [jQuery] Re: Toggling an objects visiblty without show and hide Ganeshji, Correct, As Aaron states above, 'this' refers

[jQuery] Re: Toggling an objects visiblty without show and hide

2007-07-25 Thread Michael Geary
Rob, I think you left out the return statement that you meant to put in. :-) (Outstanding explanation, BTW!) For clarity, it could be: jQuery.fn.toggleVis = function() { this.each(function() { if (this.style.visibility == 'hidden') { this.style.visibility =

[jQuery] Re: Toggling an objects visiblty without show and hide

2007-07-25 Thread Karl Swedberg
On Jul 25, 2007, at 12:26 PM, Rob Desbois wrote: I see now that an object in jQuery does not have a visibility directly, it needs a class assigned to it, so that is why example 2 doesn't work. Not entirely sure what you mean by this..? Well, the main point is that the jQuery object is not

[jQuery] Re: Toggling an objects visiblty without show and hide

2007-07-25 Thread Mike Alsup
It would have been far better if each passed the DOM element as an argument to the inner function, instead of using this: It does pass the element, so if you prefer you could write code like: $('.stuff').each(function(index, element) { element.style.visibility = 'hidden'; }); Personally,

[jQuery] Re: Toggling an objects visiblty without show and hide

2007-07-25 Thread Mike Alsup
:-) Mike, I just reread your email and see that you pointed this out already! Sorry! Mike On 7/25/07, Mike Alsup [EMAIL PROTECTED] wrote: It would have been far better if each passed the DOM element as an argument to the inner function, instead of using this: It does pass the element,

[jQuery] Re: Toggling an objects visiblty without show and hide

2007-07-25 Thread Klaus Hartl
Michael Geary wrote: Rob, I think you left out the return statement that you meant to put in. :-) (Outstanding explanation, BTW!) For clarity, it could be: jQuery.fn.toggleVis = function() { this.each(function() { if (this.style.visibility == 'hidden') {

[jQuery] Re: Toggling an objects visiblty without show and hide

2007-07-25 Thread Michael Geary
From: Michael Geary The use of this inside an each loop is one of the two major design errors in jQuery (the other being the event system, which I'll get to another day). Just to avoid any possible misunderstanding, I think everyone knows I consider jQuery to be a brilliant piece of

[jQuery] Re: Toggling an objects visiblty without show and hide

2007-07-25 Thread Mitchell Waite
is hover not a good solution? Mitch -Original Message- From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Michael Geary Sent: Wednesday, July 25, 2007 10:10 AM To: jquery-en@googlegroups.com Subject: [jQuery] Re: Toggling an objects visiblty without show and hide

[jQuery] Re: Toggling an objects visiblty without show and hide

2007-07-25 Thread Brandon Aaron
-en@googlegroups.com Subject: [jQuery] Re: Toggling an objects visiblty without show and hide Rob, I think you left out the return statement that you meant to put in. :-) (Outstanding explanation, BTW!) For clarity, it could be: jQuery.fn.toggleVis = function() { this.each

[jQuery] Re: Toggling an objects visiblty without show and hide

2007-07-25 Thread Mitchell Waite
, July 25, 2007 5:17 PM To: jquery-en@googlegroups.com Subject: [jQuery] Re: Toggling an objects visiblty without show and hide The hover method takes two functions. One for the mouseover and one for the mouseout. Here are the docs for the hover method: http://jquery.bassistance.de/api-browser

[jQuery] Re: Toggling an objects visiblty without show and hide

2007-07-25 Thread Mitchell Waite
] On Behalf Of Mitchell Waite Sent: Wednesday, July 25, 2007 7:34 PM To: jquery-en@googlegroups.com Subject: [jQuery] Re: Toggling an objects visiblty without show and hide Ok here is the skinny (I think I am getting this down) http://www.whatbird.com/wwwroot/3statebutton_3.html (uses layers

[jQuery] Re: Toggling an objects visiblty without show and hide

2007-07-25 Thread Joel Birch
Ha, you beat me by this much, Karl. Plus yours works, whereas mine is missing a dollar sign right before document ready :( Joel. On 26/07/2007, at 2:36 PM, Karl Swedberg wrote: I didn't make it simpler, really, but I did optimize it a bit. --Karl _ Karl Swedberg

[jQuery] Re: Toggling an objects visiblty without show and hide

2007-07-25 Thread Mitchell Waite
@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Karl Swedberg Sent: Wednesday, July 25, 2007 10:15 AM To: jquery-en@googlegroups.com Subject: [jQuery] Re: Toggling an objects visiblty without show and hide On Jul 25, 2007, at 12:26 PM, Rob Desbois wrote: I see now that an object

[jQuery] Re: Toggling an objects visiblty without show and hide

2007-07-25 Thread Karl Swedberg
PM To: jquery-en@googlegroups.com Subject: [jQuery] Re: Toggling an objects visiblty without show and hide Ok here is the skinny (I think I am getting this down) http://www.whatbird.com/wwwroot/3statebutton_3.html (uses layers) $(document).ready(function(){ $(#showPic

[jQuery] Re: Toggling an objects visiblty without show and hide

2007-07-25 Thread Joel Birch
On 26/07/2007, at 1:42 PM, Mitchell Waite wrote: I defy anyone to make this simpler (and work as well)! This may or may not look simpler, but its more optimised and more maintainable :) (document).ready(function(){ var myClass = hidden,

[jQuery] Re: Toggling an objects visiblty without show and hide

2007-07-24 Thread Rob Desbois
For information, the reason that works is that setting {visibility:hidden} hides the element but the element's box still affects layout. Setting {display:none} suppresses box generation altogether. (From http://www.w3.org/TR/REC-CSS2/visufx.html#visibility) --rob On 7/24/07, Aaron Heimlich

[jQuery] Re: Toggling an objects visiblty without show and hide

2007-07-24 Thread Mitchell Waite
'; } }; From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Aaron Heimlich Sent: Monday, July 23, 2007 6:01 PM To: jquery-en@googlegroups.com Subject: [jQuery] Re: Toggling an objects visiblty without show and hide jQuery.fn.toggleVis = function() { // Here, this is the jQuery

[jQuery] Re: Toggling an objects visiblty without show and hide

2007-07-24 Thread Aaron Heimlich
On 7/24/07, Mitchell Waite [EMAIL PROTECTED] wrote: What does hit mean A jQuery object is an pseudo-array[1] that contains all of the HTML elements selected by a give selector. So $(div.foo); is a pseudo-array of all of the div elements on the page that have the class foo. By hit, I mean

[jQuery] Re: Toggling an objects visiblty without show and hide

2007-07-24 Thread Mitchell Waite
to toggle the visibility a function in jQuery. From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Aaron Heimlich Sent: Tuesday, July 24, 2007 10:40 AM To: jquery-en@googlegroups.com Subject: [jQuery] Re: Toggling an objects visiblty without show and hide On 7/24/07

[jQuery] Re: Toggling an objects visiblty without show and hide

2007-07-24 Thread Aaron Heimlich
Well you should have mentioned that in the beginning. But, that doesn't mean that my plugin isn't usable. On 7/24/07, Mitchell Waite [EMAIL PROTECTED] wrote: I have a link called 'Change the cats visibility'. I have a div with a cat image inside it. I would like that particular link to change

[jQuery] Re: Toggling an objects visiblty without show and hide

2007-07-24 Thread Mitchell Waite
@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Mitchell Waite Sent: Tuesday, July 24, 2007 11:08 AM To: jquery-en@googlegroups.com Subject: [jQuery] Re: Toggling an objects visiblty without show and hide I don't think you understand my question. I have a link called 'Change the cats

[jQuery] Re: Toggling an objects visiblty without show and hide

2007-07-24 Thread Mitchell Waite
: Tuesday, July 24, 2007 12:45 PM To: jquery-en@googlegroups.com Subject: [jQuery] Re: Toggling an objects visiblty without show and hide My apology for the confusion. I should have just posted the darn code. I'll remember this in the future. I had one typo, left out the # for the container

[jQuery] Re: Toggling an objects visiblty without show and hide

2007-07-24 Thread Aaron Heimlich
On 7/24/07, Mitchell Waite [EMAIL PROTECTED] wrote: jQuery.fn.toggleVis = function() { if(chesireCat.style.visibility == 'hidden') { chesireCat.style.visibility = 'visible'; } else { chesireCat.style.visibility = 'hidden'; } }; That works