Hello, I have sage 8.2.1. I executed the following command:
bower install jquery -backstretch --save
my bower.json
I’ve read in various parts that I have to edit a file / some files manually to make it work, but i don’t know which ones.
Thanks in advance for any advice on how to solve my issue.
The gulp file works off the main declaration in each bower.json. The default for backstretch is simple:
{
"name": "jquery-backstretch",
"description": "A simple jQuery plugin that allows you to add a dynamically-resized, slideshow-capable background image to any page or element.",
"version": "2.1.15",
"homepage": "http://www.jquery-backstretch.com/",
"author": {
"name": "Scott Robbin",
"email": "scott@robbin.co",
"url": "http://srobbin.com"
},
"main": ["jquery.backstretch.js"],
"dependencies": {
"jquery": ">=1.9.x"
},
"repository": {
"type": "git",
"url": "git://github.com/jquery-backstretch/jquery-backstretch.git"
},
"ignore": [
"Gruntfile.js",
This file has been truncated. show original
So unless you need any more files from that package, you should be good. If not, you set up overrides in the Sage themes bower.json
Thanks for your response. Sadly it didn’t help.
There is already a jquery-backstretch folder in bower_components folder that contains the file you mentioned.
The problem I’m having is that the loading of the plugin fails when I’m opening the website in the browser.
Error: Uncaught TypeError: Cannot read property ‘backstretch’ of undefined
Any ideas?
Sorry, but I have to ask, you ran gulp after installing with Bower, correct?
yes, i execute gulp and gulp --production in assets folder
And are there any errors when you do that? What’s the output of those commands?
The problem was that $ is not declared, so use jQuery and had no difficulty. ¿Is there any way to use $?
Thanks a lot for the help
ben
September 27, 2015, 8:00pm
8
Thanks for your help, but I’m not sure how what you sent me can help with my issue.
Eduardo_Bustos:
The problem was that $ is not declared, so use jQuery and had no difficulty. ¿Is there any way to use $?
Thanks a lot for the help
This didn’t answer my question about if there were any errors when running gulp.
Excuse me, I had no mistakes when occupying jQuery instead of $.
gulp, I get no errors
In that case, what Ben said is correct. jQuery is loaded in no conflict mode, and should be standard in basically every theme to have to use a jQuery no conflict wrapper: wp_enqueue_script() | Function | WordPress Developer Resources
And that’s exactly what the main.js file in Sage does, along with allowing you to use JavaScript on particular pages: https://github.com/roots/sage/blob/master/assets/scripts/main.js#L77
Thank you very much for the explanation. I just understand how it works.