0

I'm trying to use data-interchange from Foundation 5 with slim as follows:

= image_tag('',  'data-interchange' => "[#{image_path('umed-image-large.jpg')}, (medium)], [#{image_path('umed-image-small.jpg')}, (small-only)]")

The problem is that it works the first time when loading the page but when clicking on a logo in the nav bar (the url is the same), the image is no more displaed. I observed the generated HTML in the Chrome console when the image is displayed:

<img data-interchange="[/assets/umed-image-large-45e4ffd1823f658bf167972ba4a8cad74797963d9a8906f65a8710d1c7458145.jpg, (medium)], [/assets/umed-image-small-97b7dfa3c6ca88e76b355eece97b723f458ae455f501013d1b0084ce0f5bd953.jpg, (small-only)]" src="/assets/umed-image-large-45e4ffd1823f658bf167972ba4a8cad74797963d9a8906f65a8710d1c7458145.jpg" data-uuid="interchange-j30j01nh0">

And here is the HTML when there is no image:

<img data-interchange="[/assets/umed-image-large-45e4ffd1823f658bf167972ba4a8cad74797963d9a8906f65a8710d1c7458145.jpg, (medium)], [/assets/umed-image-small-97b7dfa3c6ca88e76b355eece97b723f458ae455f501013d1b0084ce0f5bd953.jpg, (small-only)]" src="">

As you see, there is no src data in the latter case. Any idea what is wrong here ? Thank you.

danopz
  • 3,310
  • 5
  • 31
  • 42
belgoros
  • 3,590
  • 7
  • 38
  • 76
  • I'm not sure what you're asking, if there is no image there is an empty `src` attribute. Do you need to have no `src` attribute at all or what? I've never used Foundation. – Eyeslandic May 22 '17 at 21:11
  • @Iceman: as I told, the image should be always be there. The problem is that it i snot the case. That's why I joinded 2 cases: when the image is displayed and the 2d - when not. The HTML is different, but slim code is the same. – belgoros May 22 '17 at 21:22
  • Yes, but isn't the javascript in Foundation updating the image and what you see in the chrome console is the updated html, not the one slim generates initially. – Eyeslandic May 22 '17 at 21:24
  • Even after removing Rails image_tag helper and using just pure HTML img tag: `` it fails to be displayed properly. – belgoros May 23 '17 at 06:45

0 Answers0