Link prepended to div with jQuery can't be used as selector for another bind -



Link prepended to div with jQuery can't be used as selector for another bind -

i trying implement feature can pin elements main content area smaller div. feature works expected.

$('.pin').bind('click', function() { $('#sbstar').prepend($(this).parent().parent().parent('.leaf').clone(true)); });

edit: changing clone() clone(true), per vega's suggestion, fixed before problem (below), has not resolved completely. trying expand button different behaviour depending on whether in #sbstar or in main content area. unfortunately, ('#sbstar .expand') still doesn't work.

$('#sbstar .expand').bind('click', function() { console.log('expand'); });

for reference, html:

<article class="leaf"> <footer> <aside class="left"> <a href="#" class="expand">e</a> <a href="#sbstar" class="pin">p</a> </aside> </footer> </article>

original issue: $('.expand').bind('click', function() { console.log('expand'); });

you can 1 of next prepare issue,

a. utilize clone(true) - true indicates whether event handlers , info should copied along elements.

b. bind event handler function after clone.

function myhanlder() { console.log('expand'); } .clone().bind('click', myhandler);

c. utilize delegated events.

$('#sbstar').on ('click', '.expand', function () { ... });

jquery

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -