Hi robing,

I'm not perfectly clear on what you want to do, but might want to try changing these lines:

                $('#image_folder_button').click(function(){
                        $('.image_folder_dropdown').toggle();
                })

to this:

                $('#image_folder_button').click(function(){
                        var $ifDrop = $('.image_folder_dropdown');
                        if ($ifDrop.is(':visible') {
                                $ifDrop.hide();
                        } else {
                                $ifDrop.show();
                        }
                });

The .toggle() method works on an "every other" basis. So, each click on that particular element will attempt to alternately show and hide it, even if some other action has shown or hidden it in the meantime.

My modification uses the .is() method to check for the visibility of the element and hides or shows it accordingly.

Hope that helps.

--Karl
_________________
Karl Swedberg
www.englishrules.com
www.learningjquery.com



On Oct 10, 2007, at 12:44 AM, robing wrote:


Hi this is my first post to this group so please forgive me for any
errors I make.
The problem I am having is that I show a div element that contains
form elements, and inside this elements is another element that i want
to toggle.
How ever when I show the outer element using  using button A  I can
toggle the inner element fine, and I then hide the outer element using
button b.
When I open up the same element in the same way the inner element will
not toggle, but if i toggle the outer element using button a the inner
element works.

what do i need to do so that the inner element will toggle when i show
the outer with button a  and hide with button b and then open it up
with button a again?

$('#add_image').click(function(){

                //show a div element with some form fields
                $('.add_image_container').show();

                //here is inner element within the above element that i want to
                //toggle to show and hide, css is initialy set to display:none;
                $('#image_folder_button').click(function(){
                        $('.image_folder_dropdown').toggle();


                })
                //this is button b that i want to use to hide the outer element
                $('#cancel_add').click(function(){
                        $('.add_image_container').hide();

                })


})//end of add image


Reply via email to