I am getting data in an array which I need to bind to the label below is my code. When the array is empty I need to bind no records found which are working but I need to bind the data in the array to the label. Suppose if I have 2 items in the array I need to bind two items i.e. slider 1 should have one item and again after sliding to the right I need to bind the second item.
If more than 1 item is there then the right slider should be enabled and if it has only 1 item right slider should be disabled if there are no items both the sliders should be disabled.
The issue is in my array if i am getting 2 items after the loop execution.
0: {Actid: 33463, Subject: 'ABC', Description: 'ABCD', Startdate: '0001-01-01T00:00:00', Enddate: '0001-01-01T00:00:00', …}
1: {Actid: 33466, Subject: 'DEF', Description: 'Test', Startdate: '0001-01-01T00:00:00', Enddate: '0001-01-01T00:00:00', …}
It should bind ABC for the first slider and since i have second record it should show div when i slide the right slider.
If i have only one instead of two it should show ABC with sliders disabled.
If there are 3 array items for the first it should show the first subject, when i silde right it should show second array value and again if i click right arrow it should show third array value.
Below is the code
success: function (data) {
if (data.length == 0) {
$('.swiper-wrapper').append('<div class="swiper-slide">No rocords found</div>');
} else {
if (data != null || data != 0 || data != "") {
$('.swiper-wrapper').append('<div class="swiper-slide">Name : ' + data.Subject + '<br />Number: ' + data.Subject + '</div>');
}
}
new Swiper('.swiper-container', {
spaceBetween: 30,
centeredSlides: true,
autoplay: false,
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev'
}
});
}