Note that there are some explanatory texts on larger screens.

plurals
  1. POIs it possible to stop child click events propagating to parents when handled by .live()?
    primarykey
    data
    text
    <p>I have 'Back Board' on my images and content over here: <a href="http://syndex.me" rel="noreferrer">http://syndex.me</a> So basically, you click on an image, it will overlay a info panel above the clicked content.</p> <p>I want to do two things:</p> <ul> <li>Click on the background of the site to fade out the currently opened info panel</li> <li>Be able to click on a tag, link, or social icon <strong>within</strong> the info panel without triggering it's parent function, which is too fade out again.</li> </ul> <p>I cannot use stopPropagation for the child click being superseded by the parent click as i need the click events to be handled by .live() <a href="http://api.jquery.com/event.stopPropagation/" rel="noreferrer">(see documentation)</a> This is due to the fact that posts are being dynamically loaded.</p> <p>I cannot just say something like: $("#Background").click(function(){//fade out the Info Board} Because that is being covered by the entire post wrapper, and i can't put an event ont hat because then I'm even deeper in the dilemma of parents taking over children's events :-)</p> <p>So far I'm at least able to have just one infoboard open (i.e I click on one image, then another, it will close the already opened one, and open the current one. So this part is all good:</p> <pre><code> $('.theContent:not(.clicked)').live("click", function () { $(this).children('.postInfo').fadeIn(400); $(".clicked").each(function() { $(this).find('.postInfo').fadeOut(400); $(this).removeClass('clicked'); }); $(this).addClass("clicked"); }); $('.clicked').live("click", function () { $(".clicked").each(function() { $(this).find('.postInfo').fadeOut(400); $(this).removeClass('clicked'); }); }); </code></pre> <p>Re .live(), .delegate() and .stopPropogation():</p> <blockquote> <p><em>Since the .live() method handles events once they have propagated to the top of the document, it is not possible to stop propagation of live events. Similarly, events handled by .delegate() will propagate to the elements to which they are delegated; event handlers bound on any elements below it in the DOM tree will already have been executed by the time the delegated event handler is called. These handlers, therefore, may prevent the delegated handler from triggering by calling event.stopPropagation() or returning false.</em></p> </blockquote>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload