There was a Type Error that was not caught - The property 'owlcarousel' could not be read because it was null

This issue has been addressed previously, but despite implementing the suggestions provided, I am still encountering the same problem. Uncaught typeError: Cannot read property 'owlCarousel' of null

I have a Magento store using the Ultimo template. My goal is to replicate the brands slider on the homepage to showcase credentials. The slider utilizes Lazy Owl, and I've inserted the CSS, jQuery, and HTML into my CMS Homepage exclusively. However, the problem persists regardless of my attempts, such as switching from $ to jQuery or employing noConflict.

Website URL: www.lifestylemedicine.co.uk

The code snippet:

<style>
#owl-demo .item{
background: #3fbf79;
padding: 30px 0px;
margin: 10px;
color: #FFF;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
text-align: center;
}
.customNavigation{
text-align: center;
}

.customNavigation a{
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
</style>
<script>
$(document).ready(function() {

var owl = $("#owl-demo");

owl.owlCarousel({
  items : 10, //10 items above 1000px browser width
  itemsDesktop : [1000,5], //5 items between 1000px and 901px
  itemsDesktopSmall : [900,3], // betweem 900px and 601px
  itemsTablet: [600,2], //2 items between 600 and 0
  itemsMobile : false // itemsMobile disabled - inherit from itemsTablet option
});

// Custom Navigation Events
$(".next").click(function(){
owl.trigger('owl.next');
})
$(".prev").click(function(){
owl.trigger('owl.prev');
})
$(".play").click(function(){
owl.trigger('owl.play',1000); //owl.play event accept autoPlay speed as     second parameter
})
$(".stop").click(function(){
owl.trigger('owl.stop');
})

});
</script>
<h3 class="section-title padding-right">OUR CREDENTIALS</h3>
<div id="owl-demo" class="owl-carousel owl-theme">
<div class="item"><h1>1</h1></div>
<div class="item"><h1>2</h1></div>
<div class="item"><h1>3</h1></div>
<div class="item"><h1>4</h1></div>
<div class="item"><h1>5</h1></div>
<div class="item"><h1>6</h1></div>
<div class="item"><h1>7</h1></div>
<div class="item"><h1>8</h1></div>
<div class="item"><h1>9</h1></div>
<div class="item"><h1>10</h1></div>
</div>

<div class="customNavigation">
<a class="btn prev">Previous</a>
<a class="btn next">Next</a>
</div>

Your assistance would be greatly appreciated.

Answer №1

Before proceeding, make sure to confirm that the js file is loaded:

owl.owlCarousel({
  items : 10, //10 items above 1000px browser width
  itemsDesktop : [1000,5], //5 items between 1000px and 901px
  itemsDesktopSmall : [900,3], // betweem 900px and 601px
  itemsTablet: [600,2], //2 items between 600 and 0
  itemsMobile : false // itemsMobile disabled - inherit from itemsTablet option
});

The library inclusion should be as follows:

<!-- Include js plugin -->
<script src="assets/owl-carousel/owl.carousel.js"></script>

Additionally, ensure that you have the Jquery library installed.

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

What is the process for creating an animation with a filter or toggle effect?

I am eager to create an interactive animation for my search engine on my website, but I'm struggling with where to begin. Here is the relevant HTML snippet: <div id="companyRoster" class="companyRoster container"> <div class="row mb-2"& ...

Send a troublesome string from the client to the server and receive the identical string in return

Having trouble sending the game record from my client to my server: [Event "fics server game, rated blitz match"] [Site "Internet Chess Server: freechess.org 5000"] [Date "1999.11.07"] [Time "06:26:??"] [Round " ...

Tips for changing the style ID depending on the variable value

Currently, I am exploring the possibility of switching CSS styles using jQuery through a simple if condition. Is there an easy method to switch styles based on IDs? In my case, I have two CSS blocks each with different IDs. Here is an example: <style ...

I possess an assortment of objects and I must retrieve specific information about them based on two data points

Managing a collection of items can be challenging, especially when filtering based on specific data points. For example, let's say we have a collection of action objects like {name: Detail}, {name: Spec}... and two data points determining which action ...

Create a dynamic onClick event script and integrate it into Google Optimize

I need to incorporate a button element into my website using Google Optimize for an experiment. This button needs to trigger a specific script depending on the variation of the experiment. I have attempted two different methods: <button id="my-button" ...

Currently, my nextjs project is up and running smoothly in vscode. When I execute `npm run dev` in the terminal, everything seems to be working fine. However

Whenever I run npm run dev in my terminal to start a nextJS project, it shows the following output: > [email protected] dev > next dev ready - started server on 0.0.0.0:3000, url: http://localhost:3000 but when I try to access it in the browser, ...

Execute JavaScript AJAX Request On Page Load

I am facing an issue with creating an onload event in which an AJAX function needs to be called and passed a value. The challenge lies in the fact that I have both my header and footer split into sections via PHP, therefore I cannot place it on the body ta ...

hide bootstrap confirmation when clicking off of it

I'm facing an issue with the bootstrap confirmation plugin. I want to close all confirmations when the user clicks outside of the confirmation pop-up. However, the current implementation is causing the confirmation to close everytime there is a click ...

What is the best way to retrieve the root binding node from a viewmodel in order to apply jQuery.blockUI when performing an AJAX post request?

Within my code, I have a designated DIV element that serves as the root node for applying knockout bindings like so: ko.applyBindings(viewModel, document.getElementById('myContainerDiv')); In all of my viewmodel types, there is a generic post m ...

Steps for adding an overlaying image in HTML and SCSS

First step: background-size: cover; Second step: background-size: contain; background-repeat: no-repeat; The third step is what I need: the first background image to be set as cover and the second one as an overlay with no-repeat Currently, my HTML incl ...

Zod vow denial: ZodError consistently delivers an empty array

My goal is to validate data received from the backend following a specific TypeScript structure. export interface Booking { locationId: string; bookingId: number; spotId: string; from: string; to: string; status: "pending" | "con ...

Tips on redirecting the user to the page they have selected

<section> <div class="container"> <select name="semester" id="select-semester"> <option value="no-semester">choose a semester</option> <option valu ...

The link color in the UL class fails to supersede the default color for the div element

I've created a div that includes the following styles: #main-alt-2 a:link {color:#39c;} #main-alt-2 a:visited {color:#39c;} Within this same div, I have defined styles for a UL as follows: ul.menu a:link { font-weight:bold; display:block; text-deco ...

Anticipated () to initiate arrow function, however encountered ';' rather than '=>'

Dealing with a chunk of jQuery code has been quite challenging for me. The main goal is to invoke a partial method, which works fine on the first button click, but subsequent clicks result in an error. Expected () to start arrow function, but got ' ...

Steps to generate a nested list with heading tag elements in the exact order as in the DOM structure

My HTML document is full of h1, h2, h3, h4 tags with nesting. Let's take a look at an example. <h2>About cars</h2> <p>Information about cats</p> <h2>About bikes</h2> <p>Information about bikes</p> ...

what is the process for installing non-NPM libraries with browserify?

My current project involves working with Angular and using Bower as the package manager. However, I now want to integrate some npm modules in the browser by using Browserify. Initially, I was able to npm install angular angular-ui-router --save for my sta ...

Cursor starts to move to the front of the input line after every single letter with a 1 millisecond delay while browsing certain websites, such as the comments section on Youtube

When I type a letter in the field, within 1 millisecond the cursor jumps to the beginning of the line in the typing field, causing text to be typed in reverse. I can only send messages on certain sites, such as YouTube comments and Yandex Translate, for ex ...

Saving Information Using Express-Session

Imagine you need a user to input their email and then save it to be accessible across multiple web pages. Would it be considered a poor practice to store this email in the session object of express-session? For example: req.session.email = '<user ...

Encountering a series of errors in Discord.js v14 while executing a specific

UPDATE :- After troubleshooting, I discovered that the previous error stemmed from my command handler itself! However, now I am encountering a whole bunch of new errors... actually, multiple errors. So, I'm in desperate need of assistance. (Note: Apol ...

JQuery content displaying only on the first instance

<script> $(document).ready(function () { $('nav>li').hide(); $('ul').hide(); $('h2').hide(); $('a.btnDown').click(function () { $('body').css('background&apos ...