diff --git a/js/bootstrap-carousel.js b/js/bootstrap-carousel.js index 0d7167e1c2..0852cf3f43 100644 --- a/js/bootstrap-carousel.js +++ b/js/bootstrap-carousel.js @@ -167,7 +167,7 @@ $('body').on('click.carousel.data-api', '[data-slide]', function ( e ) { var $this = $(this), href , $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7 - , options = !$target.data('modal') && $.extend({}, $target.data(), $this.data()) + , options = !$target.data('carousel') && $.extend({}, $target.data(), $this.data()) $target.carousel(options) e.preventDefault() }) diff --git a/js/tests/unit/bootstrap-carousel.js b/js/tests/unit/bootstrap-carousel.js index 5ac9fb2d81..fbcbb5b17e 100644 --- a/js/tests/unit/bootstrap-carousel.js +++ b/js/tests/unit/bootstrap-carousel.js @@ -37,6 +37,26 @@ $(function () { start(); }) .carousel('next') - }) + test("should set interval from data attribute", function () { + var template = $(''); + template.attr("data-interval", 1814); + + template.appendTo("body"); + $('[data-slide]').first().click(); + ok($('#myCarousel').data('carousel').options.interval == 1814); + $('#myCarousel').remove(); + + template.appendTo("body").attr("data-modal", "foobar"); + $('[data-slide]').first().click(); + ok($('#myCarousel').data('carousel').options.interval == 1814, "even if there is an data-modal attribute set"); + $('#myCarousel').remove(); + + template.appendTo("body"); + $('[data-slide]').first().click(); + $('#myCarousel').attr('data-interval', 1860); + $('[data-slide]').first().click(); + ok($('#myCarousel').data('carousel').options.interval == 1814, "attributes should be read only on intitialization"); + $('#myCarousel').remove(); + }) }) \ No newline at end of file