Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The plugin is not firing off the script #3

Open
RailsCod3rFuture opened this issue Dec 31, 2014 · 3 comments
Open

The plugin is not firing off the script #3

RailsCod3rFuture opened this issue Dec 31, 2014 · 3 comments

Comments

@RailsCod3rFuture
Copy link

backstretch-rails is loading as I can see in the console, but the plugin itself is not working in my view.

At the end of my body, I placed $.backstretch("<%= image_tag 'movie-photo.png' %>"); inside of a script tag, but the background isn't changing at all. I'm using jquery-rails 4.0.2.

Update: The gem is working when I place the code inside of the application.js, and also when I place the code inside of a stand-alone JS file. But either way, backstretch-js is overriding the background for all views/controllers. How can I stop it from going beyond a single page?

@ahmeij
Copy link
Contributor

ahmeij commented Jan 2, 2015

Try calling it after the document has fully loaded, a common jquery method of doing this is the following:

$( document ).ready(function() {
  console.log( "ready!" );
  $.backstretch("<%= image_tag 'movie-photo.png' %>");
});

@RailsCod3rFuture
Copy link
Author

Your method works much better and it's cleaner. Thank you.

@ahmeij
Copy link
Contributor

ahmeij commented Jan 6, 2015

You're welcome :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants