heckmac
heckmac

Reputation: 243

foundation interchange callback

I'm trying to use the callback of interchange plugin. This is my code:

$('#project_slideshow').on('replace', 'img', function (e, new_path, original_path) {
   $(e.currentTarget).load(function () {
     console.log($(this).width());
   })
});

The problem here is that when I resize the window the parsed elements are every time more and more.

I'm also trying to understand if there is a way to use this callback to send back custom values like the media query it is currently using.

Thanks

Upvotes: 1

Views: 511

Answers (1)

Rob M.
Rob M.

Reputation: 36521

I think what you meant to use was .on('load'), as load actually loads data from the server:

http://api.jquery.com/load/

$('#project_slideshow').on('replace', 'img', function (e, new_path, original_path) {
   $(e.currentTarget).on('load', function () {
     console.log($(this).width());
   })
});

You can use window.matchMedia method to detect the current media query, article here

Upvotes: 2

Related Questions