не меняется объект
Коллеги, доброго времени суток, уперся в проблему, прошу помощи, советом, суть такая, приложение пишу на es6 классами. Про DOMContentLoaded инициализирую приложение:
import App from './app.js'; const app = new App(); Самый App: export default class Application { constructor() { eventEmitter.init(); this.main = document.getElementById('application'); this.controls = new Controls(this.main); // контролы this.searchList = new SearchList(this.main); // список объектов this.controller = new Controller(); // обработчик кнопок } } Ну и так далее по списку, суть приложения - работа с таблицами продажными. this.searcList это таблица обычная, с данными. У меня стоит задача сделать фильтр для этой таблицы. Но видимо не судьба. В SearchList я создаю класс фильтр: constructor(container, array) { this.bus = eventEmitter.bus; this.container = container; this.filter = this.container.querySelector('.filter'); this.config = new Config(array); // текущее состояние фильтра this.bus.on('filter:sortTable', this.sortTable.bind(this)); this.bus.on('filter:utils', this.openFilterUtils.bind(this)); this.bus.on('filter:saveUtils', this.saveUtils.bind(this)); this.bus.on('filter:checkCategory', this.checkCategory.bind(this)); this.bus.on('filter:areaRange', this.areaRange.bind(this)); } Суть следующая, я загружаю таблицу в контейнер, далее собираю this.config - который включает в себя параметры по которым нужно собрать фильтр. При первой загрузке страницы все нормально, собирается и фильтруется, но вот если я закрою таблицу и потом опять открою то конфиг остается прежним, хотя по сценарию он должен пересобираться: Это метод open из класса SearchList: open(array) { if (array.length) { if (this.container.getAttribute('data-status') === 'open') return; this.filter = new Filter(this.container, array); // создаем фильтр this.build(); // строим таблицу this.filter.build((objects) => { // строим фильтр и отдаем объекты для тела таблицы this.buildTable(objects); // строим тело таблицы this.container.setAttribute('data-status', 'open'); // выводим }); } else { this.bus.emit('controls:off'); this.bus.emit('popup:open', `<p>Данных нет!.</p>`); } } Далее сам фильтр: constructor(container, array) { this.bus = eventEmitter.bus; this.container = container; this.filter = this.container.querySelector('.filter'); this.config = new Config(array); // текущее состояние фильтра this.bus.on('filter:sortTable', this.sortTable.bind(this)); this.bus.on('filter:utils', this.openFilterUtils.bind(this)); this.bus.on('filter:saveUtils', this.saveUtils.bind(this)); this.bus.on('filter:checkCategory', this.checkCategory.bind(this)); this.bus.on('filter:areaRange', this.areaRange.bind(this)); } build(callback) { // первое открытие // тут сборка html блоков } собственно сам this.config: constructor(array) { this.bus = eventEmitter.bus; this.objects = array; // массив объектов this.areas = []; this.instance = {}; this.init(); } init() { // заводские настройки this.instance.area = []; this.instance.utils = []; let cats = {}; let areas = []; this.objects.forEach(item => { areas.push(item.area_value); cats[item.category] = true; }); this.instance.area = [Math.min.apply(Math, areas), Math.max.apply(Math, areas)]; this.areas = [Math.min.apply(Math, areas), Math.max.apply(Math, areas)]; for (let key in cats) { let obj = { cat_code: '', cat_name: key, cat_select: true, resolutions: [] }; let resolutions = []; this.objects.forEach(item => { if (obj.cat_name.indexOf(item.category) !== -1) { resolutions.push(item.util_code); obj.cat_code = item.category_type; } }); util.clearArray(resolutions, array => { array.forEach(res => { obj.resolutions.push({ name: res, select: true }); }); this.instance.utils.push(obj); }); } this.getCounter(); } Видимо ссылки на старый объект или свойства не дают ему придти в новое состояние Заранее благодарю, за дельные советы |
Часовой пояс GMT +3, время: 07:22. |