eldarion / eldarion-ajax

a library for adding declarative ajax functionality to your website
BSD 3-Clause "New" or "Revised" License
758 stars 153 forks source link

Success events not triggered when element is replaced #35

Closed evilmango closed 11 years ago

evilmango commented 11 years ago

The bootstrap-ajax:success event is not triggered when data-replace or fragments replaces $el.

e.g.

// this listener is never called
$('body').on('bootstrap-ajax:success', function() {
   console.log('bootstrap-ajax:success triggered');
});
<div id="my_div">
    <a href="/some/ajax/handler" class="ajax" data-replace="#my_div">Hit me</a>
</div>

I noticed issue 24 (Triggering of success and error events) https://github.com/eldarion/bootstrap-ajax/issues/24 changed the behaviour to trigger on the element itself.

I'm not sure what the solution is here. Perhaps to trigger on the document if the element has been removed from the DOM?

paltman commented 11 years ago

@evilmango this should be resolved now that the event is triggered before the processing.