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

Lost context on each() #9

Open
denisborovikov opened this issue Jun 28, 2015 · 3 comments
Open

Lost context on each() #9

denisborovikov opened this issue Jun 28, 2015 · 3 comments
Milestone

Comments

@denisborovikov
Copy link

<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?

@maxpoletaev maxpoletaev added this to the 1.4 milestone Jun 28, 2015
@maxpoletaev
Copy link
Owner

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.

@denisborovikov
Copy link
Author

Thanks! Looking forward to the fix.

@ghost
Copy link

ghost commented Oct 27, 2015

$(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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants