JavaScript function not firing off for owlcarousel-rails plugin

The javascript is not working for ‘owlcarousel-rails’ plugin. I have the
gem and require statements for application.css/application.js setup
properly.

//= require owl.carousel
*= require owl.carousel
*= require owl.theme

I called the plugin with:

        <script type= 'text/javascript' >
          $(".owl-carousel").owlCarousel();
        </script> in my <header></header>
<%= image_tag 'JohnsPhotos/weekend-getaway1.jpg' %>
<%= image_tag 'JohnsPhotos/weekend-getaway2.jpg' %>
the tags for the plugin are mid page in the

Why isn’t the javascript/css displaying the photos?

On Wed, Dec 24, 2014 at 10:06 AM, David W. [email protected]
wrote:

The javascript is not working for ‘owlcarousel-rails’ plugin.

Disclaimer: never heard of this plugin, but —

          $(".owl-carousel").owlCarousel();

if you’re calling that method before any such elements exist in the
DOM, I’d expect exactly nothing to happen :slight_smile:

Have you looked at the JS console/log to see if there are errors?


Hassan S. ------------------------ [email protected]

twitter: @hassan

Hassan S. wrote in post #1165339:

On Wed, Dec 24, 2014 at 10:06 AM, David W. [email protected]
wrote:

The javascript is not working for ‘owlcarousel-rails’ plugin.

Disclaimer: never heard of this plugin, but —

          $(".owl-carousel").owlCarousel();

if you’re calling that method before any such elements exist in the
DOM, I’d expect exactly nothing to happen :slight_smile:

Have you looked at the JS console/log to see if there are errors?


Hassan S. ------------------------ [email protected]
Hassan Schroeder | about.me
twitter: @hassan

Can you test this gem to see if it’s working on Ruby on Rails 4 for you?
It’s not even showing the images that are inside of the div tags.
Normally, it would even if the JavaScript was acting up.

Hassan S. wrote in post #1165339:

On Wed, Dec 24, 2014 at 10:06 AM, David W. [email protected]
wrote:

The javascript is not working for ‘owlcarousel-rails’ plugin.

Disclaimer: never heard of this plugin, but —

          $(".owl-carousel").owlCarousel();

if you’re calling that method before any such elements exist in the
DOM, I’d expect exactly nothing to happen :slight_smile:

Have you looked at the JS console/log to see if there are errors?


Hassan S. ------------------------ [email protected]
Hassan Schroeder | about.me
twitter: @hassan

I’ll try to call it after the div code block, and then see if the
function
fires off.

Carousel Placeholder

<%= image_tag 'Photo1'%
<%= image_tag 'Photo2'%>

I was calling an ID instead of a class with the initializer. Now, it’s
working perfectly!! Thank you all for taking the time out to guide me.

On 24 December 2014 at 21:08, David W. [email protected]
wrote:

DOM, I’d expect exactly nothing to happen :slight_smile:
Normally, it would even if the JavaScript was acting up.
View the source of the page in the browser to get a clue as to what is
going on.

Colin