jquery-carousel-lite icon indicating copy to clipboard operation
jquery-carousel-lite copied to clipboard

trigger go event doesn't work with nested carousels

Open roscopeeco opened this issue 10 years ago • 5 comments

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

roscopeeco avatar Nov 14 '14 15:11 roscopeeco

@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!

kswedberg avatar Nov 16 '14 19:11 kswedberg

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

roscopeeco avatar Feb 16 '15 14:02 roscopeeco

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

kswedberg avatar Feb 17 '15 13:02 kswedberg

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');
  }
};```

kswedberg avatar Feb 17 '15 13:02 kswedberg

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

roscopeeco avatar Feb 17 '15 13:02 roscopeeco