Activate the following and preceding elements within the 'vue-owl-carousel' component for Vue.js

I'm facing an issue with navigating to the next or previous item in the vue-owl-carousel package while using Vue and javascript.

Is there anyone who can provide assistance?

Below is the code for the carousel :

<carousel id="newGamesCarousel" :items="1" :dots="false" :nav="false" :margin="10" :key="refresh">
  <div class="newGames-item" v-for="item in newProducts">
    <div class="details">
      <div class="labels flex-wrap">
        <span class="mb-1" v-for="platform in item.platforms">{{platform.name}}</span>
        <span class="mb-1" v-for="region in item.regions">ریجن {{region.name}}</span>
      </div>
      <h2 class="gameTitle">{{item.name}}</h2>
      <div class="priceBox">
        <router-link class="add-to-cart" :to="{path: '/game/'+item.id+'/'+stringToSlug(item.title)+''}">+</router-link>
        <div class="price">
          <div class="former" v-if="item.sale_percent !== false">
            <span class="percent">%{{item.sale_percent}}</span>
            <span class="total">{{item.price}}</span>
          </div>
          <div class="later">
            {{item.regular_price}}
            <span class="unit">تومان</span>
          </div>
        </div>
      </div>
    </div>

    <figure class="image">
      <img v-bind:src="item.thumbnail_url" v-bind:alt="item.name">
    </figure>
  </div>
</carousel>

Additionally, here are the buttons for moving to the next and previous items:

<div class="arrows">
  <svg class="nextCarousel" id="newGamesNext" viewBox="0 0 24 24">
    <use xlink:href="/src/assets/imgs/sprite.svg#arrow"></use>
  </svg>
  <svg class="prevCarousel" id="newGamesPrev" viewBox="0 0 24 24">
    <use xlink:href="/src/assets/imgs/sprite.svg#arrow"></use>
  </svg>
</div>

Answer №1

Check out the documentation provided at this link: https://www.npmjs.com/package/vue-owl-carousel

You can customize previous and next buttons using slots. The buttons will only be visible when not in loop mode.

<carousel>

  <template slot="prev"><span class="prev">prev</span></template>

  <template slot="next"><span class="next">next</span></template>

</carousel>

Add the carousel tag after inserting all your slides

You can use

<template slot="{{prev/next}}">{{add your icon image here }}</template>
to handle previous and next events automatically

<template slot="prev">
   <svg class="nextCarousel" id="newGamesNext" viewBox="0 0 24 24"><use xlink:href="/src/assets/imgs/sprite.svg#arrow"></use></svg>
</template>

This should resolve your issue. If there is anything else needed, feel free to share any tutorials or documentations you have followed. Please update on whether the solution worked for you or not.

Answer №2

<v-flex>
  <span @click="$refs.prev.click()">
      Click here for previous
  </span>
  <span @click="$refs.next.click()">
      Click here for next 
  </span>
</v-flex>


<v-flex>

  <carousel>

   <template slot="prev"><span hidden ref="prev" class="prev">previous</span></template>

   <template slot="next"><span hidden  ref="next" class="next">next</span></template>

  </carousel>

</v-flex>

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

The select tag's options are empty, but the number of generated options matches the count of the data source in VUE / IONIC

I am trying to render options for a select tag using the v-for directive in Ionic/Vue. Although the data source seems to be communicating well with the component, the v-for loop is generating blank options. Please refer to the following link for more detai ...

Uploading Images Dynamically with AJAX

Can someone assist me with a multiple upload form that utilizes AJAX to upload and display an image without the need for a submit button? My issue arises when dealing with repeating forms within table rows, causing only the first form to function properly. ...

Combining items in JavaScript using a shared key

Is there a way to combine 4 separate arrays of objects into one big object based on the keys inside an object? For example: OUTPUT: What I want to achieve. [ { "bugId": "", "testerId": "", "firstName": "", "lastName": "", "country": " ...

Retrieving data from an AJAX call and populating a knockout.js observableArray()

This phenomenon confuses me. There must be some small detail that I am missing here. My goal is to load a simple observableArray in knockout using an ajax call. javascript // We initialize the array with an empty array. var data = []; var viewModel = ...

Rendering iteratively in FXML for scenarios not involving tables

What is the FXML equivalent for iterative rendering using the v-for attribute in the Vue-like markup below? <VBox> <HBox v-for="task of tasks"> <Checkbox :checked="task.isComplete"></Checkbox> ...

Retrieve the child scope of ng-repeat beyond the ng-repeat iteration and establish a two-way data binding

With my ng-repeat, I am attempting to include ng-model inside each repeated li, followed by two-way data binding outside of the ng-repeat. You can see the example in this jsbin: http://jsbin.com/yutinifivi/edit?html,js,output I have searched extensively f ...

Encountering difficulties in the installation of vuemdb

Currently, I am in the process of following the installation instructions for a newly created Vue application utilizing advanced installation steps. vue create project # include router and select vue 3 cd project vue add mdb # opt for free version # after ...

Load blender scene with functional lighting using THREE.JS GLTFLoader

Recently, I've been experimenting with the GLTFLoader feature in THREE.js along with the new blender exporter found here. After successfully adding a model with similar color material and importing the scene into my THREE.js project, I noticed that wh ...

Converting to JSON: "Property or method not supported by object"

Having a JavaScript Class with a method, but encountering an error when trying to call it toJSON. The reason behind this error remains a mystery to me. try { if (this.TabloEkId == undefined || this.TabloEkId == "") { throw errEksikVeri; } ...

Issue Encountered While Deploying Next JS Application Utilizing Dynamic Routing

I just finished developing my Personal Blog app with Next JS, but I keep encountering an error related to Dynamic Routing whenever I run npm run-script build. Below is the code for the Dynamic Route Page: import cateogaryPage from '../../styles/cards ...

React does not automatically re-render components created with the built-in function

I'm facing some confusion with the behavior in my code: I've created a component that should function as a menu using MaterialUI. The idea is that when a button in the menu is clicked, it becomes "active" and visually reflects this change by set ...

Arrange two arrays by organizing them based on the contents of one in JavaScript

Consider the following two arrays: priceArray= [1, 5, 3, 7] userIdArray=[11, 52, 41, 5] The goal is to sort the priceArray in such a way that the userIdArray also gets sorted accordingly. The desired output should look like this: priceArray= [1, 3, 5, ...

Having difficulty transitioning a function with a promise from JavaScript to TypeScript

I am currently in the process of transitioning my existing NodeJS JavaScript code to TypeScript for a NodeJS base, which will then be converted back to JavaScript when running on NodeJS. This approach helps me maintain clear types and utilize additional fe ...

Is it best practice to use the AngularFirestoreCollection for updating Firestore items in AngularFire?

Within my application, I have a list that necessitates the use of an "or" condition. However, according to the documentation: "In this case, you should create a separate query for each OR condition and merge the query results in your app." Consequently ...

Error: Authentication Error - Headers have already been sent to the client and cannot be modified

I am currently working on handling authentication errors for my website. However, when I submit incorrect data, I encounter the following error: node:internal/errors:478 ErrorCaptureStackTrace(err); ^ Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers aft ...

Obtain module-specific members through programmatic means

When working on a browser, the code may appear like this: //retrieve all enumerable properties of `this` function globalMems() { var g = this; var ret = {}; for (var prop in g) { ret[prop] = g[prop]; } return ret; } In Node.js, this does ...

experiencing a problem with the older version 1.5 of the swfobject.js software

Hello there! I am encountering an issue with swfobject.js version 1.5 specifically in IE7 and IE8. My chart is not displaying in these web browsers, but it works perfectly fine on Chrome, Firefox, and even IE 6. Do you have any suggestions on how to resolv ...

Troubleshooting a minor JavaScript loop problem

I am facing an issue with my script that retrieves data from a database. Currently, when the search() function is called by clicking a button, only one result is displayed in a new div. How can I ensure that a new div is created for each result found, rath ...

The chatbot text input feature is malfunctioning and failing to display the entered text in the chatbox

Hi there! I'm in the process of creating a chatbot using a basic input text box and button in HTML, with a php start function. Unfortunately, when I enter text into the textbox, nothing is showing up on the screen and the button doesn't seem to b ...

What could be causing the input event not to be triggered consistently when I select or highlight text?

I have implemented a 4-digit pin field with a specific behavior: when a field is filled, the focus automatically shifts to the next field (the cursor moves to the next input field). If text in a field is deleted, the text in that field is also removed and ...