문제

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?

도움이 되었습니까?

해결책

$(".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

다른 팁

There is probably no .ui-effects-transfer element until the effect starts. Here's correct answer from @kbwood.au user from jquery forum:

$('.button').click(function() {
    $('#transferEffect').remove(); // Remove any existing one
    $('<style id="transferEffect" type="text/css">' + // Add new one
        '.ui-effects-transfer { background-image: url(' + $(this).attr('src') + '); }' +
        '</style>').appendTo('head');
    $(this).effect('transfer', {to: $('.target')}, 1000);
});  
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top