On change delete everything in array and add new values in it
This question already has an answer here:
You need to clear array before pushing new value. Easy way to remove all exisiting values is to set length to 0
:
saveSelectedValue : function (e) {
var that = e.data.that,
selectArray = that.filterSelectedCategories;
selectArray.length = 0; // clear selectArray array
selectArray.push($('.posts-filter-cat').val());
console.log(selectArray);
},
链接地址: http://www.djcxy.com/p/23956.html
上一篇: 通过函数参数重置一个数组