"Call the initializer function" in Gem Docs

时间:2016-04-04 18:14:27

标签: jquery ruby-on-rails ruby owl-carousel

I am a newbie, working through a coding bootcamp and fighting my way through one of the "do it on your own" challenges. I keep seeing in these gem docs on github things like "don't forget to initialize!" stuffs and the one I specifically want to use says:

3.Call the plugin

Now call the Owl initializer function and your carousel is ready.

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

But I have now idea what this means, yet. Can anyone steer me right? THANKS!!!!

1 个答案:

答案 0 :(得分:0)

I would recommend following the ReadMe on the GitHub repository here: https://github.com/OwlCarousel2/OwlCarousel2

The initializer looks for an element in your html with the owl-carousel class. It then injects the Owl Carousel functionality into this element. The plugin comes ready to handle the content you put in the <div> Your Content </div> tags in your html.

Make sure you follow the ReadMe, and you should be fine.

One thing to note about jquery plugins is that you need to require jquery, which you can download locally or use a cdn like this <script>https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-beta1/jquery.js</script>

Also, make sure to wrap all of your javascript / jquery functions in this code to make sure your Document Object Model is loaded before trying to execute any JavaScript/Jquery:

$(document).ready(function(){
  // Your code here
});