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

trigger go event doesn't work with nested carousels #47

Open
roscopeeco opened this issue Nov 14, 2014 · 5 comments
Open

trigger go event doesn't work with nested carousels #47

roscopeeco opened this issue Nov 14, 2014 · 5 comments

Comments

@roscopeeco
Copy link

Hello

I have encountered a bug when trying to use the 'go' event with nested carousels.

When the trigger go event is executed for the child carousel - $('div.subcarousel').trigger('go', '0') - the go actually is applied to the parent carousel instead.

thanks
Ross

@kswedberg
Copy link
Owner

@roscopeeco Thanks for the report. Can you point me to a URL where I can see the problem? If not, can you provide some HTML and the code you're using so I have something to work with as I debug this?

Thanks!

@roscopeeco
Copy link
Author

Hi Karl
Sorry for the delay but i didn't actually have a reply in my browser for some reason!

I've set up a fiddle here:
http://jsfiddle.net/620rxe68/2/
Looks like the next,prev & go are not working

If you click 'next' on the parent then click on 'next'on the child - it actually goes to next on both the parent and child.

if you then click 'back' on the parent and then click 'go 0' on the child it goes to the first parent again

hope this helps

thanks

Ross

@kswedberg
Copy link
Owner

Thanks, @roscopeeco . I'll investigate as soon as I'm able.

@kswedberg
Copy link
Owner

Okay, I just took a quick look, and I saw that the problem was due to the parent's btnNext and btnPrev selectors being too general. Changing them to '.parent > .next' and `'.parent > .prev' should do the trick.

Here's a fiddle showing the fix:
http://jsfiddle.net/wLg58d70/

By the way, you could also use a function (sorry I haven't documented that yet), returning the element you want to use. For example:

var parentoptions = {
  // ... 
  btnNext: function() {
    return $(this).children('.next');
  },
  btnPrev: function() {
    return $(this).children('.prev');
  }
};```

@roscopeeco
Copy link
Author

Hi Karl

Thanks for the quick reply. Ah yes schoolboy error regarding the prev,next options BUT still got the issue with the child.trigger('go',0).

i've amended the original demo:
http://jsfiddle.net/620rxe68/6/

Thanks

ross

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

2 participants