1

Basically I have a standard imagesLoaded implementation. I want to know how can I manipulate a pre-existing variable within .done(). So basically something like this:

var p = 0;

$('#container').imagesLoaded().done( function( instance ) {
 //manipulate p variable
}); 

console.log(p);

However, p never seems to change. Also, I am using React and therefore the rendering cycles of React may complicate things? I am still kind of new to React so I am unsure if React is causing my issues or if I am just using this deferred object wrong. I appreciate any feedback. Thanks.

connected_user
  • 814
  • 1
  • 9
  • 25

1 Answers1

-1

I don't know what you're using, but I think its like this:

var p = 0;

$('#container').imagesLoaded( function() {
  p = "awesome"
  console.log(p);
});

Have a look at the documentation

Eldo.Ob
  • 774
  • 4
  • 16
  • Lets say all of this is in a function. How can I make the function return the value p (which is "awesome") from within the deferred object? – connected_user Aug 30 '16 at 13:34