Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Не срабатывает автоматическая отписка при удалении блока #1580

Open
belozer opened this issue Jun 20, 2018 · 0 comments · May be fixed by #1581

Comments

@belozer
Copy link
Member

belozer commented Jun 20, 2018

CodePen

modules.require([
  'jquery', 'i-bem-dom', 'BEMHTML', 'button'
], ($, bemDom, BEMHTML, Button) => {
  
const html = BEMHTML.apply([
  { block : 'test', js : true },
  { block : 'button', text : 'click me' }
]);
  
const Root = bemDom.declBlock('root');

bemDom.declBlock('test', {
  onSetMod : {
    js : {
      inited : function() {
        console.log('Test inited');
        const btn = this.findParentBlock(Root).findChildBlock(Button);
        this._events(btn).on('click', this._onButtonClick, this);
      }
    }
  },
  
  _onButtonClick : function() {
    console.log('On button click from _events');
  },
  
}, {
  lazyInit : false
});
  
  
bemDom.append($('.root'), html);

setTimeout(() => { 
  bemDom.destruct($('.test')); 
  console.log('Test destructed'); 
}, 500);

});

После destuct блока кликаем на кнопку и получаем в консоль:
On button click from _events

upd
возможно проблема смежная с #1525

upd
Проблему вроде починил. Осталось разобраться в причине и прислать PR

@belozer belozer linked a pull request Jun 20, 2018 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant