-
Notifications
You must be signed in to change notification settings - Fork 736
/
jcarousel.ajax.js
47 lines (39 loc) · 1.26 KB
/
jcarousel.ajax.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
(function($) {
$(function() {
var jcarousel = $('.jcarousel').jcarousel();
$('.jcarousel-control-prev')
.on('jcarouselcontrol:active', function() {
$(this).removeClass('inactive');
})
.on('jcarouselcontrol:inactive', function() {
$(this).addClass('inactive');
})
.jcarouselControl({
target: '-=1'
});
$('.jcarousel-control-next')
.on('jcarouselcontrol:active', function() {
$(this).removeClass('inactive');
})
.on('jcarouselcontrol:inactive', function() {
$(this).addClass('inactive');
})
.jcarouselControl({
target: '+=1'
});
var setup = function(data) {
var html = '<ul>';
$.each(data.items, function() {
html += '<li><img src="' + this.src + '" alt="' + this.title + '"></li>';
});
html += '</ul>';
// Append items
jcarousel
.html(html);
// Reload carousel
jcarousel
.jcarousel('reload');
};
$.getJSON('data.json', setup);
});
})(jQuery);