Search code examples
jqueryjquery-uitransferjquery-effects

jquery UI dynamically transfered img with UI/Effects/Transfer


I'm using this JQuery UI component:

http://docs.jquery.com/UI/Effects/Transfer

My code is this:

$(".button").click(function () {
  var source = $(this).attr("src");
  $(".ui-effects-transfer").css("background-image", "url("+source+")");  
  $(this).effect("transfer", { to: $(".target") }, 1000);
});

But this line doesn't affect transfer script:

$(".ui-effects-transfer").css("background-image", "url("+source+")"); 

How can I fix this?


Solution

  • $(".button").click(function () {
      var source = $(this).attr("src");
      $(this).effect("transfer", { to: $(".target") }, 1000); // <- comes first
      $(".ui-effects-transfer:last").css("background-image", "url(" + source + ")");
    });
    

    Working example