At a glance that looks like it will add lots of event handlers instead of just one and that doesn't sound like its going to be an efficiency gain over one event handler with a single comparison test. – Chris Jun 18 '10 at 12:06 Unfortunately that doesn't work. Although, this section of the code isn't broken, it's the IE 7 not accepting the code that I'm more interested in overcoming.
– aligreene Jun 18 '10 at 12:09 @chris - Yep my mistake, it still doesn't seem very efficient to be manually delegating after every event has to bubble all the way up the dom? – Haroldo Jun 18 '10 at 12:20.
I would think that the reason the toggle only shows is because the line before you are hiding everything. Its not just hiding other menus, its hiding all of them so when you toggle you are toggling something hidden to make it visible. You probably want to keep track of what is currently being shown (store the currently visible menu in a variable) and then you can check whether you are supposed to be hiding it or not.
That's exactly why it's happening - thanks a million. I'll let you know how I get on. – aligreene Jun 18 '10 at 12:15.
First off the: $("body"). Click(function(e){ if(e.target. ClassName!
== "actions_image") { $(". Actions_image").next().hide(); } }); stands alone, so does not need to be in that function - which seems to me to add that handler each time you click an image. SO I would put it outside the click handler for the image.
Second, section_actions_menu: function(event){ ... with the specific: onclick="section_actions_menu(event);" together is the same as: $('. Actions_image'). Click(function(e){ }); SO, I would remove the onclick=... and change to the specific jQuery handler which separates the markup from the behavior (no click function call on the element at all, it is all in the code).
Then we can handle the event for the click. SO, I end up with this script: $(document). Ready(function() { $("body").
Click(function(e) { if (e.target. ClassName! == "actions_image") { $(".
Actions_image").next().hide(); }; }); $('. Actions_image'). Click(function(e) { if (e.target.next().
Is(':visible')) { $(". Actions_image").next().hide(); } else { $(". Actions_image").next().hide(); //hides all menus if any showing e.target.next().show();//shows this specific one.
}; }); }); NOTE: this: $(". Actions_image").next().hide(); could also be: $(". Actions_image").
Next('. Toggle').hide(); to use your class.
Mark - thanks for the reply. I was shown another method, which I posted the answer to if you wanted to see. Also took away the onclick= as well.
Thanks – aligreene Jun 21 '10 at 15:14.
It turns out someone much cleverer than me also pointed out this method: section_actions_menu: function() { var action_menu = $(". Actions_image"); action_menu. Live('click', function(e) { var other_action_menus = $(".
Actions_image"). Not($(this)); other_action_menus.next().hide(); $(this).next().toggle(); }); and together with this: $("body"). Click(function(e) { //hides menu when clicking outside the menu if(e.target.
ClassName! == "actions_image") { $(". Actions_image").next().hide(); } }); ... it allows to show and hide the menu when you click on an element with class ".
Actions_image", hides the menu when you click outside ". Actions_image" and hides other menus that might be showing when you click on another element with class ". Actions_menu".
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.