converting regular javascript implementation to ruby on rails javascript implementation -



converting regular javascript implementation to ruby on rails javascript implementation -

i have next code in regular index.html

<!doctype html> <html lang="en"> <head> <title>template</title> <!-- bootstrap core css --> <link href="assets/css/bootstrap.css" rel="stylesheet"> <!--external css--> <link href="assets/font-awesome/css/font-awesome.css" rel="stylesheet" /> <!-- custom styles template --> <link href="assets/css/style.css" rel="stylesheet"> <link href="assets/css/style-responsive.css" rel="stylesheet"> </head> <body> <!-- bunch of other code..... --> <!-- want ! --> <!-- js placed @ end of document pages load faster --> <script src="assets/js/jquery.js"></script> <script src="assets/js/bootstrap.min.js"></script> <!--backstretch--> <!-- can utilize image of whatever size. script stretch fit in screen size.--> <script type="text/javascript" src="assets/js/jquery.backstretch.min.js"></script> <script> $.backstretch("assets/img/solar.jpg", {speed: 500}); </script> <!-- end of want --> </body> </html>

at end of index.html, want incorporate jquery javascript , jquery-backstretch.min file rails application. there standard rails way of doing this?

i've tried inject next rails new.html.erb

<!-- js placed @ end of document pages load faster --> <%= javascript_include_tag '../assets/javascripts/jquery.js', 'data-turbolinks-track' => true %> <!--backstretch--> <!-- can utilize image of whatever size. script stretch fit in screen size.--> <%= javascript_include_tag '../assets/javascripts/jquery.backstretch.min.js"', 'data-turbolinks-track' => true %> <script> $.backstretch("assets/images/solar.jpg", {speed: 500}); </script>

and

<!-- js placed @ end of document pages load faster --> <script src="assets/javascripts/jquery.js"></script> <!--backstretch--> <!-- can utilize image of whatever size. script stretch fit in screen size.--> <script type="text/javascript" src="assets/javascripts/jquery.backstretch.min.js"></script> <script> $.backstretch("assets/images/solar.jpg", {speed: 500}); </script>

but unfortunately both of them appears wrong.

what should do?

edit:

i've added modified files application.js looks this

//= require jquery //= require jquery_ujs //= require jquery.backstretch.min //= require turbolinks //= require_tree .

and i've since removed corresponding script tags new.html.erb. now, @ bottom, contains script call

<script> $.backstretch("assets/images/solar.jpg", {speed: 500}); </script>

but unfortunately still incorrect

i have solution might able use. javascript backstretch plugin working method. i'm using on 1 page since backstretch fire off on pages if add together require statement , javascript method application.js file.

step #1 1 install gem backstretch-rails step #2 remove //= require backstretch step #3 add together <%= javascript_include_tag "jquery.backstretch" %>

<%= javascript_include_tag "backstretch-landing-index" %>

to index.html.erb view. top of body tag

step #4 add together

rails.application.config.assets.precompile += %w( jquery.backstretch.js ) rails.application.config.assets.precompile += %w( backstretch-landing-index.js )

to initializers/assets.rb file

inside of backstretch-landing-index.js add together function want call

$.backstretch([ "http://dl.dropbox.com/u/515046/www/outside.jpg" , "http://dl.dropbox.com/u/515046/www/garfield-interior.jpg" , "http://dl.dropbox.com/u/515046/www/cheers.jpg" ], {duration: 3000, fade: 750});

it works!! total path link of image. "/assets/photo1.png" me

javascript ruby-on-rails ruby-on-rails-4 asset-pipeline

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -