Brandonmchu
Brandonmchu

Reputation: 57

Javascript is in Generated HTML, but none of the javascript works

I'm in a rails 3.2 app, and I'm using the gem for skroller https://github.com/Prinzhorn/skrollr

My application.js requires skroller

//= require jquery-1.9.1.min
//= require jquery_ujs
//= require jquery.numeric
//= require skrollr

...and my generated html includes the expected javascript

<script src="/assets/skrollr.js?body=1" type="text/javascript"></script>

The gem is supposed to allow you to use html5 tags to create some scrolling effects, the example one they give is

 <div data-0="background-color:rgb(255,0,0);" data-500="background-color:rgb(0,0,255);">
      WOOOT
    </div>

I placed this in the view to test it out, but even though the correct script is generating, it's simply not working and I can't figure out why

My assumption is that since it's generating, then it's nothing to do with how i setup the views or application.js... looking for any help, thanks

Upvotes: 1

Views: 226

Answers (1)

000
000

Reputation: 27247

You need to tell skrollr to initialize itself.

Add

<script type="text/javascript">
$(function() {
    skrollr.init();
});
</script>

somewhere after you load the external files.

There are many options available to you here too. See: https://github.com/Prinzhorn/skrollr#skrollrinitoptions

Upvotes: 3

Related Questions