How to make an interactive slideshow using bootstrap and handlebars

I am currently utilizing bootstrap in combination with handlebars to develop a carousel. The goal is to display specific items retrieved from my database within the carousel.

However, I have encountered an issue where instead of smoothly transitioning to the second slide, the carousel skips through it and suddenly disappears from the page.

The database fetches two test items as follows:

{ _id: 5d28ad4eec77e8389c56792b,
  slug: '5d28ad4eec77e8389c56792b',
  __v: 1,
  name: 'Test ',
  publishedDate: 2019-07-11T23:00:00.000Z,
  review: 'This was good',
  image: [ 5ce83014af97ea064c5a750d ] },{ _id: 5d29fab5c8a3794a081f65d6,
  slug: 'test2',
  name: 'test2',
  __v: 0,
  publishedDate: 2019-07-12T23:00:00.000Z,
  review: 'fdfsfdsdfsdfdsfsdfs',
  image: [] }

Here is the code for the carousel:

<div class="container-fluid" id="anchorJump">
    <div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">

      
      <!-- Wrapper for slides -->
      <div class="carousel-inner">
        {{#each testimonials}}
        {{#if @first}}
        <div class="item active">
          <div class="carousel-item active">{{{this.review}}}
            {{else}}
            <div class="carousel-item">{{{this.review}}}
              {{/if}}
              {{/each}}
            </div>
          </div>
        </div>
      </div>

    </div>
  </div>

Additionally, the javascript code for the carousel operation:

$('.carousel').carousel({
    interval: 6000,
    pause: "false",
    wrap:true
  });

Answer №1

I finally managed to make it work after troubleshooting the loop as per my earlier comment.

<script id='wrapper' type='text/x-handlebars-template'>
  <div >
     <div class="carousel-inner">
       {{#each testimonials}}
       <div class="item {{#if @first }}active {{/if}}">
         <div class="carousel-item {{#if @first }}active {{/if}}">{{this.review}}

           <div class="carousel-item">{{this.review}}


           </div>
         </div>
       </div>
       {{/each}}      
     </div>
     </div>
</script>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Disabling a button in Vue.js when form inputs remain unchanged

I am facing a challenge with multiple forms that were created from an API. I need to constantly monitor if the input values within each form have been changed in order to toggle the button between disabled and enabled states. To address this issue, I atte ...

Tips for assigning array variables to elements in querySelectorAll [Pure JavaScript]

I need help with assigning values from an array to elements selected by the querySelectorAll function. I am trying to write code that will change the text to different values in the array when the browser width is below 768px, but I'm facing some chal ...

Looking for assistance with importing OBJ and MTL files into Three.js?

I'm encountering a strange issue while attempting to load an OBJ and MTL file in Three.js using the OBJMTLLoader() function and am unable to find a solution online. My project structure includes an index.html file and a js folder with all the necessar ...

When a user clicks on the product id field, I would like to add my data underneath the table and then conduct a search

When adding data to a table, I noticed that it is being added at the top instead of below the table, I implemented a search feature where the user can enter a product id, but I cannot seem to locate the error in my code, Is there a way to add a search fiel ...

What is the process of generating clozed text using HTML and CSS?

Is there a method to conceal text and create an underline of identical length in an HTML document? In this technique, certain highlighted words remain hidden, substituted with underlines that match the original text's length precisely. Additionally, a ...

Maximizing the use of JavaScript's prototype.js library: Passing parameters to callback functions

My understanding of JavaScript is limited to using it for Dynamic HTML. However, I am now exploring Ajax and facing an issue with the code below (taken from and modified to suit my requirements). I need to pass the update_id parameter to the onSubmit fun ...

navigation bar: retain link hover state even after displaying sub-menu

My navigation bar has submenus with background images in .png format. Only 3 links in my navbar have these submenus. The issue I am facing is that when the menu link is in a hover state and the submenu is being hovered over, the nav link loses its hover st ...

Transitioning code from gatsby to nextjs has caused an issue with the aws-sdk integration

I have successfully integrated the aws-sdk with Gatsby by using a .env file to upload a file to an S3 bucket. Now, I am in the process of migrating this functionality to Next.js, but I'm encountering an error in Next.js. Uncaught (in promise) Credent ...

Removing an item from a numeric array in mongoose: Best practices

I received a document structured like this: { "_id" : "5339be1d9a703ab8708b45675339bed39aac7", "description" : "data", "name" : "data", "members" : [ { "user" : { "$ref" : "users", "$id" ...

Ensure the source Option is correctly updated in the bootstrap-typeahead.js file

Check out this demo where, after adding the value "Alaska," the autocomplete feature is updated to prevent displaying "Alaska" again. var newSource = this.source .slice(0,pos) .concat(this.source.slice(pos+1)); this ...

Issue with Bootstrap 4 nested collapse: "data-parent" attribute malfunctioning

I'm looking to implement the collapse data-parent options in a way that mimics traditional accordion behavior: all collapsible elements under a specified parent should close when a new one is opened. However, I am encountering issues with this setup. ...

Step-by-step guide on populating a state using an array

I am having trouble populating a list within a state using the set method, as the state remains empty App.js // Initiates the secrets word game const startGame = () => { // pick word and pick category const { word, category } = pickWordAndCat ...

Set datatables to perform regex searches that specifically target the beginning of text

Here is my JavaScript code for using datatables, I want to have the search function only filter results that start with the specified keyword. For example, if I have [hello, hello_all, all_hello] and my search term is "hel", I should only get [hello, hel ...

Is it possible to utilize recursion for adding new values in multidimensional arrays in this scenario?

how do we add a new value to each array in the container if the number of fruits is less than the desired target? for example: - we need to add new fruits to these 2d arrays: - The maximum number of "apple" in a container should be 3 fruits, if ther ...

Saving an HTML5 canvas image to an MSSQL varbinary(max) field: A step-by-step guide

SAVING CANVAS IMAGE AS BASE64 STRING TO HIDDEN FIELD This script binds the base64 string to a hidden field on click event. save.addEventListener('click', function (event) { var dataUrl = canvas.toDataURL(); $('txtbx').val(dataUrl) ...

The system encountered an issue while trying to access the property 'play' of null

I'm attempting to create a customized audio player, but I've encountered an error: "cannot read property 'play' of null". After some research, I discovered that this could be due to the function being called before the ID exists. Howeve ...

Information on Vue.js and Firebase User Data

I am currently working on an application that integrates Vue.js and Firebase. So far, I have successfully implemented the login functionality using email/password and can store the user information from firebase.auth() in the state.currentUser of Vue.js. ...

The v-leave-active animation is functioning correctly, however, the v-enter-active animation is not working as expected on the <transition-group>

In my Vue 3 project, I have created a custom component called Accordion. The purpose of this component is to toggle the display of its content when a button (created using a div instead of a <button> tag) is clicked. The Accordion utilizes a <slot ...

Ways to implement collapsible functionality into table rows

I have a table on my website and I want to initially display only 3 rows. When the user clicks on the 'more' button, I want the rest of the rows to be displayed. However, when I tried implementing this with code, I encountered rendering issues. I ...

The functionality of AJAX is hindered in the browser when attempting to fetch data from a URL

Lately, I've been encountering a strange issue when trying to fetch data from a URL. $.ajax({ url: 'URLHERE', dataType: 'html', success: function(data) { //function 2 var xml = $.parseXML(data) $(xml).find('StopLoca ...