I am in need of assistance as I have encountered a major issue that has halted my work progress for several days. My goal is to implement a feature that allows users to navigate between different days both forwards and backwards. While the functionality itself is working fine, the main problem I am facing is related to displaying these days within a modal. Unfortunately, when the days are shown in the modal, the navigation between them does not function correctly.
If you would like to take a look at the complete code, it can be found here: Jquery, Css Moving between week days with previous next buttons - Carousel
Modal:
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
<!-- Indicators -->
<div class="day-picker">
<button type="button" class="day-picker-nav prev">
<svg width="12" height="14" xmlns="http://www.w3.org/2000/svg" transform="rotate(180)">
<path class="svg-stroke-container" stroke-linejoin="round" stroke-linecap="round" fill-rule="evenodd" fill="none" stroke="#D70F64" d="m3.5,1.5l5,5.5l-5,5.5"></path>
</svg>
</button>
<div class="day-picker-overflow">
<ul class="day-picker-week">
@foreach($calender_days as $key => $calender_day)
<li>
<label class="day-picker-day">
<input type="radio" value="" name="day-picker" />
<span class="day-value button-toggle">{{$calender_day['day_text']}} <span class="day-number">{{(int)$calender_day['day_date']}}</span></span>
</label>
</li>
@endforeach
</ul>
</div>
<button type="button" class="day-picker-nav next">
<svg width="12" height="14" xmlns="http://www.w3.org/2000/svg" transform="rotate(0)">
<path class="svg-stroke-container" stroke-linejoin="round" stroke-linecap="round" fill-rule="evenodd" fill="none" stroke="#D70F64" d="m3.5,1.5l5,5.5l-5,5.5"></path>
</svg>
</button>
</div>
</div>
</div>
</div>
Jquery:
$(".day-picker").each(function() {
const $week = $(".day-picker-week", this);
const $days = $(".day-value", this);
const $prev = $(".prev", this);
const $next = $(".next", this);
const visible = Math.floor($week.width() / $days.outerWidth(true));
const perc = 100 / visible;
const tot = $days.length;
const steps = tot - visible;
let c = 0;
const anim = () => {
$week.css({transform: `translateX(${-perc*c}%)`});
}
$prev.on("click", function() {
c -= 1;
if (c < 0) c = steps;
anim();
});
$next.on("click", function() {
c += 1;
if (c > steps) c = 0;
anim();
});
});