mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-29 16:19:53 +02:00
add relatedTarget to carousel slide event
This commit is contained in:
16
js/tests/unit/bootstrap-carousel.js
vendored
16
js/tests/unit/bootstrap-carousel.js
vendored
@@ -12,7 +12,7 @@ $(function () {
|
||||
|
||||
test("should not fire sliden when slide is prevented", function () {
|
||||
$.support.transition = false
|
||||
stop();
|
||||
stop()
|
||||
$('<div class="carousel"/>')
|
||||
.bind('slide', function (e) {
|
||||
e.preventDefault();
|
||||
@@ -25,4 +25,18 @@ $(function () {
|
||||
.carousel('next')
|
||||
})
|
||||
|
||||
test("should fire slide event with relatedTarget", function () {
|
||||
var template = '<div id="myCarousel" class="carousel slide"><div class="carousel-inner"><div class="item active"><img src="assets/img/bootstrap-mdo-sfmoma-01.jpg" alt=""><div class="carousel-caption"><h4>{{_i}}First Thumbnail label{{/i}}</h4><p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p></div></div><div class="item"><img src="assets/img/bootstrap-mdo-sfmoma-02.jpg" alt=""><div class="carousel-caption"><h4>{{_i}}Second Thumbnail label{{/i}}</h4><p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p></div></div><div class="item"><img src="assets/img/bootstrap-mdo-sfmoma-03.jpg" alt=""><div class="carousel-caption"><h4>{{_i}}Third Thumbnail label{{/i}}</h4><p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p></div></div></div><a class="left carousel-control" href="#myCarousel" data-slide="prev">‹</a><a class="right carousel-control" href="#myCarousel" data-slide="next">›</a></div>'
|
||||
$.support.transition = false
|
||||
stop()
|
||||
$(template)
|
||||
.on('slide', function (e) {
|
||||
e.preventDefault();
|
||||
ok(e.relatedTarget);
|
||||
ok($(e.relatedTarget).hasClass('item'));
|
||||
start();
|
||||
})
|
||||
.carousel('next')
|
||||
})
|
||||
|
||||
})
|
Reference in New Issue
Block a user