Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
57
rated 0 times [  64] [ 7]  / answers: 1 / hits: 8439  / 5 Years ago, sun, october 6, 2019, 12:00:00

I'm trying to display a horizontal timeline on my HTML page. I'm having trouble with my swiper slider, the next and prev buttons do not work at all, I've included the library as well, still doesn't work, I don't understand why. No errors are shown in console, buttons are clickable but do not function at all. How do I fix this? Below is the code



<div id=app class=container>
<div class=row>
<div class=col-md-12>
<div class=swiper-container>
<p class=swiper-control>
<button type=button class=btn btn-default btn-sm prev-slide>Prev</button>
<button type=button class=btn btn-default btn-sm next-slide>Next</button>
</p>
<div class=swiper-wrapper timeline>
<div class=swiper-slide v-for=item in steps>
<div class=timestamp>
<span class=date>{{item.dateLabel}}<span>
</div>
<div class=status>
<span>{{item.title}}</span>
</div>
</div>
</div>
<!-- Add Pagination -->
<div class=swiper-pagination></div>
</div>
</div>
</div>
</div>


<script src=https://cdn.jsdelivr.net/npm/[email protected]></script>
<script>
const data = [{
dateLabel: 'January 2017',
title: 'Gathering Information'
},
{
dateLabel: 'February 2017',
title: 'Planning'
},
{
dateLabel: 'March 2017',
title: 'Design'
},
{
dateLabel: 'April 2017',
title: 'Content Writing and Assembly'
},
{
dateLabel: 'May 2017',
title: 'Coding'
},
{
dateLabel: 'June 2017',
title: 'Testing, Review & Launch'
},
{
dateLabel: 'July 2017',
title: 'Maintenance'
}
];

new Vue({
el: '#app',
data: {
steps: data,
},
mounted() {
var swiper = new Swiper('.swiper-container', {
slidesPerView: 4,
paginationClickable: true,
grabCursor: true,
paginationClickable: true,
nextButton: '.next-slide',
prevButton: '.prev-slide',
});
}
})



More From » html

 Answers
3

Rearranged a few scripts. Made some changes to Swiper config. Please see it this helps!





<!DOCTYPE html>
<html lang=en>
<head>
<meta charset=UTF-8 />
<meta name=viewport content=width=device-width, initial-scale=1.0 />
<meta http-equiv=X-UA-Compatible content=ie=edge />
<title>Document</title>
<script src=https://cdn.jsdelivr.net/npm/[email protected]></script>
<link rel=stylesheet href=https://unpkg.com/swiper/css/swiper.min.css>
</head>
<body>
<div id=app class=container>
<div class=row>
<div class=col-md-12>
<div class=swiper-container>
<p class=swiper-control>
<button type=button class=btn btn-default btn-sm prev-slide>Prev</button>
<button type=button class=btn btn-default btn-sm next-slide>Next</button>
</p>
<div class=swiper-wrapper timeline>
<div class=swiper-slide v-for=item in steps>
<div class=timestamp>
<span class=date>{{item.dateLabel}}<span>
</div>
<div class=status>
<span>{{item.title}}</span>
</div>
</div>
</div>
<!-- Add Pagination -->
<div class=swiper-pagination></div>
</div>
</div>
</div>
</div>

<script
src=https://cdnjs.cloudflare.com/ajax/libs/Swiper/4.5.1/js/swiper.min.js
integrity=sha256-4sETKhh3aSyi6NRiA+qunPaTawqSMDQca/xLWu27Hg4=
crossorigin=anonymous
></script>
<script>
const data = [
{
dateLabel: January 2017,
title: Gathering Information
},
{
dateLabel: February 2017,
title: Planning
},
{
dateLabel: March 2017,
title: Design
},
{
dateLabel: April 2017,
title: Content Writing and Assembly
},
{
dateLabel: May 2017,
title: Coding
},
{
dateLabel: June 2017,
title: Testing, Review & Launch
},
{
dateLabel: July 2017,
title: Maintenance
}
];

new Vue({
el: #app,
data: {
steps: data
},
mounted() {

var swiper = new Swiper(.swiper-container, {
slidesPerView: 3,
spaceBetween: 30,
pagination: {
el: .swiper-pagination,
clickable: true
},
navigation: {
nextEl: .next-slide,
prevEl: .prev-slide
}
});
}
});
</script>
</body>
</html>




[#6026] Wednesday, October 2, 2019, 5 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
zariahdiamondz

Total Points: 649
Total Questions: 109
Total Answers: 88

Location: Tajikistan
Member since Thu, Apr 14, 2022
2 Years ago
;