0👍
✅
Just reset accordion id after ajax success:
like this:
$('#accordion'+acc_id).attr('id','accordion');
have an example
function change_acc(acc_id){
$('#accordion').attr('id','accordion'+acc_id);
$.ajax({
url: "<?php base_url();?>/charts/getsome",
method: "POST",
data: {
graphYear:acc_id
},
success: function(data) {
$('#accordion'+acc_id).attr('id','accordion');
var data = JSON.parse(data);
var month = [];
var customers = [];
// var margin = [];
for(var i in data) {
month.push("" + data[i].dated);
customers.push(data[i].profit);
// margin.push(data[i].margin);
}
var chartdata = {
labels: month,
datasets : [
{
label: 'monthly customers for Year '+acc_id,
backgroundColor: 'rgba(200, 200, 200, 0.75)',
borderColor: 'rgba(200, 200, 200, 0.75)',
hoverBackgroundColor: 'rgba(200, 200, 200, .45)',
hoverBorderColor: 'rgba(200, 200, 200, 1)',
data: customers,
fill: true,
lineTension:0
}
]
};
var frame = $("#mycanvas");
var barGraph = new Chart(frame, {
type: 'line',
data: chartdata,
// options: {
// responsive: true,
// tooltips: {
// callbacks: {
// afterBody: function(t, d) {
// return 'Margin: ' + margin[t[0].index];
// }
// }
// }
// }
});
},
error: function(data) {
console.log(data);
}
});
}
Source:stackexchange.com