I'm trying to use interchange to change images based on the screen size.
However, when interchange is initialised no images load. Then when I resize the browser (1024px and lower) I get an error in the console saying:
Uncaught TypeError: Cannot read property 'nodeName' of undefined
Which relates to line 47 of foundation.interchange.js, which is:
if (/IMG/.test(el[0].nodeName)) {
The code I'm trying to use is:
<img data-interchange="[http://www.example.com/image.png, (default)], [http://www.exmaple.com/image-large.png, (large)]" />
This is completely standard as per Zurb's documentation. I've made sure the images exist, which they do.
I'm using Foundation version 5.2.2.
Any ideas?
I had this issue and resolved it by doing some simple tests...
Try some of these:
Why? - This will ensure that you avoid duplicate function calls within the plugin.
How? - Ctrl-f (find) the word 'interchange.js' on the view source page
This is the best way to check for it, especially if you're working in an MVC or nested webforms framework.
eg. IN THIS ORDER....
Why? - The interchange needs to exist already once foundation intializes I believe.
I hope these options help - sorry if it's a bit basic - but worth a try all the same Cheers