2

I am building a simple form inside an Owl Carousel but I can't get it to work on their version 2.

The problem is when the user click inside the input type on the second version the console log gives an error :Uncaught TypeError: Cannot read property 'name' of undefined.

on the first version everything works fine. Here is a fiddle for v1 I was just wondering if somebody can take a look, I tried using mouseDrag:false but it doesn't do the trick.

And here is the link for version 2 and the code goes like this:

$(document).ready(function () {
    var owl = $('.owl-carousel');
    owl.owlCarousel({
        items:1,
        mouseDrag:false
    });
    // Go to the next item
    $('.customNextBtn').click(function () {
        owl.trigger('next.owl.carousel');
    })
});
Cœur
  • 37,241
  • 25
  • 195
  • 267
ryangus
  • 679
  • 3
  • 8
  • 22

1 Answers1

1

This post is over 3 years old, but I came across the same issue. It took me hours to find a solution, so I want to share it with anyone who might be interested.

I don't know what exactly causes the error, but I figured that the error is thrown whenever the focusout event is triggered. Unfortunately, preventing focusout from bubbling didn't solve my problem.

After browsing the project's issues on GitHub, I came across this article where user with nickname "ghost" suggests a solution. The problem can be avoided by disabling onclick and onchange events of the input.

This code worked for me:

$("#controls").on('click change', function(event) {
    event.stopPropagation();
});

where #controls is a <div> wrapper around all my form controls

RN92
  • 1,380
  • 1
  • 13
  • 32
Alex Shnyrov
  • 548
  • 5
  • 12
  • 1
    Yep this was long time ago, even the examples no longer work, I stopped using owl carousel some time ago and moved to [siema] https://github.com/pawelgrzybek/siema and [vue.js] https://vuejs.org/ , anyways, I will take your word for it and accept the answer so someone else can benefit for it, thanks for the answer. – ryangus Feb 26 '19 at 21:42