I have a div with dynamically content.
<div id='data'></div>
inside div is a table with class.
<table class="table table-hover table-expandable table-striped">
'table-expandable' execute with this js file
<script src="<?php echo base_url();?>assets_d/expand/bootstrap-table-expandable.js"></script>
when page refresh this work fine, but when I load dynamically div with ajax
$(document.getElementById(data)).html(dynamiclyTable);
script on js file does not work, this is script on js file
(function ($) {
$(function () {
var i=0;
$('.table-expandable').each(function () {
var table = $(this);
i++;
alert(i);
table.children('thead').children('tr').append('<th></th>');
table.children('tbody').children('tr').filter(':even').each(function () {
var element = $(this);
element.append('<td><div class="table-expandable-arrow"></div></td>');
});
table.children('tbody').children('tr').filter(':odd').hide();
table.children('tbody').children('tr').filter(':even').on('click',function () {
var element = $(this);
element.next('tr').toggle('slow');
element.find(".table-expandable-arrow").toggleClass("up");
});
});
});
})(jQuery);
Is there a way to call js file after div load dynamically content ? Thanks