Rerun Javascript On Successful Ajax Call
I have a delete button with the remote: true option set: # _categories.html.erb <%= link_to 'Destroy', category, method: :delete, data: { confirm: 'Are you sure?' }, remote: tr
Solution 1:
I don't know If I have understand you 100% but looks like you want to add the events after AJAX success?
$(function () {
functionInitializeEvents() {
/* new category */
$('#new_admin_category').on('ajax:success', function (event, data, status, xhr) {
$("#dashboard_categories").html(data.html);
InitializeEvents();
});
/* delete category */
$('a[data-remote]').on('ajax:success', function (event, data, status, xhr) {
$("#dashboard_categories").html(data.html);
InitializeEvents();
});
}
InitializeEvents();
});
Hope it helps :)
Post a Comment for "Rerun Javascript On Successful Ajax Call"