loop through jquery list of elements
$('.mdm-period-select').on('change', function() { // bind change function to all elements with class mdm-period-select
var period = $(this).val();
$('.mdm-period-select').each(function(i, obj) { //loop through the list of selected elements
// console.log($(this))
$(this).selectpicker('val', period) // set value of each select without trigger change event
});
if (period === 'YTD') {
localforage.getItem('dataset_ytd').then(function(value) {
window.dataset = value;
reloadData()
}).catch(function (error) {
console.log(error)
});
} else if (period === 'MTD') {
localforage.getItem('dataset_mtd').then(function(value) {
window.dataset = value;
reloadData()
}).catch(function (error) {
console.log(error)
});
} else {
localforage.getItem('dataset_ttm').then(function(value) {
window.dataset = value;
reloadData()
}).catch(function (error) {
console.log(error)
});
}
});
Was this article helpful?
This article is viewed 25 times!