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

When selector is a class quojs dont respect "this" as current object #14

Closed
oliverhr opened this issue Feb 18, 2012 · 3 comments
Closed

Comments

@oliverhr
Copy link
Contributor

Check this comparison

With jquery this work as expected

<script type="text/javascript">
$(function() {
    $('.swipe').on('click', function () {       
        $('.bubble', this).toggleClass('hidden');
    });
});
</script>

With QuoJS all elements with the specified selector are affected

<script type="text/javascript">
$$(document).ready(function() {
    $$('.swipe').tap(function() {
        $$('.bubble', this).toggleClass('hidden');
    });
});
</script>

On this elements

<ul>
  <li class="swipe" id="111">Item 111
    <div class="bubble onright red hidden" data-icon="remove" id="aaa">Remove</div>
  <li class="swipe" id="222">Item 222
    <div class="bubble onright red hidden" data-icon="remove" id="bbb">Remove</div>
  <li class="swipe" id="333">Item 333
    <div class="bubble onright red hidden" data-icon="remove" id="ccc">Remove</div>
</ul>
@jcalonso
Copy link

I have the same problem.

lng.dom("article#enbici-providersView li").tap(function(event){

        lng.dom('.check', this).show();

    });

and every "li" in my "ul" appears with a check :/

@oliverhr
Copy link
Contributor Author

Hi jcalonso, I bypass the problem easily using children function, but I report the issue because is kinda weird. ;)

<script type="text/javascript">
$$(document).ready(function() {
    $$('.swipe').tap(function() {
        $$(this).children('.bubble').toggleClass('hidden');
    });
});
</script>

Hope this help to improve Quo.

@jcalonso
Copy link

Thank you oliverhr, it worked perfect! :)

@soyjavi soyjavi closed this as completed Mar 19, 2012
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

No branches or pull requests

3 participants