jquery-bem icon indicating copy to clipboard operation
jquery-bem copied to clipboard

Lost context on each()

Open denisborovikov opened this issue 9 years ago • 3 comments

<div class="foo bar"></div>

$('.foo').each(function () {
  $(this).mod('modifier', true);
});

Result <div class="foo bar bar_modifier"></div>

I know, that ctx() helps in this case, but do you think that it should remember context?

denisborovikov avatar Jun 28 '15 15:06 denisborovikov

Current context based on selector property of jQuery object. Inside of each the selector is lost. You should set context again.

$(this).ctx('foo').mod('modifier', true);

I already know about this issue. But fix will take a long time.

maxpoletaev avatar Jun 28 '15 15:06 maxpoletaev

Thanks! Looking forward to the fix.

denisborovikov avatar Jun 28 '15 15:06 denisborovikov

$(this).ctx('form__input') or $(this).block().elem('input') It looks bad. Why not just use the first class? Maybe just be take from the source code of BEM? Really need this plugin. I sincerely hope for improvement.

ghost avatar Oct 27 '15 17:10 ghost