Menu icon Foundation
Interchange within Interchange

Is it possible to have nested Interchange functionality?

For example template1 loading template2, and template2 then loads template3.

Thanks,
Nemanja

interchangenested

Is it possible to have nested Interchange functionality?

For example template1 loading template2, and template2 then loads template3.

Thanks,
Nemanja

Karl Ward over 5 years ago

That would require reflowing Interchange after each nested interchange has loaded. I don't think I would recommend a process like that, as its kinda slow linear- and blocking load process just to get some data into the page. Check the #events documentation, and the #reflow paragraph below it:
http://foundation.zurb.com/docs/components/interchange.html#events

Something like this I would guess:

$(document).on('replace', '#element', function (e, new_path, original_path) {
  $(document).foundation('interchange', 'reflow');
});

Nemanja Milosavljevic over 5 years ago

Thanks for the quick reply.

What I'll actually have is this:
Load a template with interchange, then, with interchange again, depending on the screen size load different images.

I've tried that approach and it works on replace, but initially it's not loading the default image.

And also, If I define an image with interchange, initially nothing is loaded, as if the "default" option is not doing anything.

Nemanja Milosavljevic over 5 years ago

Also, when the change occurs I get this error:

For just image: Uncaught TypeError: Cannot read property 'nodeName' of undefined

For template: Uncaught TypeError: undefined is not a function

Karl Ward over 5 years ago

I don't know ... I could take a look if you have a live example.

Nemanja Milosavljevic over 5 years ago

Hi Karl,

unfortunately the project is still in the early development stage, so I cannot show it to you.

Btw I've solved the error that has been showing "Uncaught TypeError" and it was due to the jquery 2 that came with the Foundation 5 (5.0.0 and 5.2.2) by using jquery 1.10.2.

Alexander Andersson over 5 years ago

Hi Nemanja!

I am getting "Uncaught TypeError: Cannot read property 'nodeName' of undefined" in the replace directive. I'm using interchange v5.0.3.
If I override the replace directive and add the following in the beginning it works fine:

if(!el[0])
return;

Changing jQuery version doesn't do anything for me.
Am I missing something else? I'm using custom named queries if that can have something to do with it.