2011-05-12 69 views
5

我希望能夠關閉此對話框,並將它用這個傳遞給一個對象jQuery的對話框打開/關閉使用轉移效應

我試過......不是運氣

close: function() { 
    $(this).effect('transfer', { to: "#smpb_info_btn", className: "ui-effects-transfer" }, 500);$(this).remove(); 
} 

現在我特林這個......仍然沒有運氣

$PMinfo_Dialog.dialog({ 
     autoOpen: true, 
     height: 250, 
     width: 600, 
     modal: false, 
     draggable: false, 
     resizable: false, 
     hide:{ 
      effect:"transfer", 
      options:{from: "#smpb_info_btn", className: "ui-effects-transfer"}, 
      speed:500 
      } , 

     close: function() { $(this).remove();}, 
     }); 
    $PMinfo_Dialog.dialog("open"); 
+0

輕微切線代碼審查:如果您的d ialog被設置爲autoOpen:true,爲什麼你之後立即調用dialog(「open」)?它應該在沒有多餘的呼叫時自動打開。 – 2011-05-12 20:22:54

回答

3

working jsFiddle demo應是你所需要的:

HTML:

<div id="PMinfo">Hello</div> 

<button id="smpb_info_btn">Info</button> 

CSS:

.ui-effects-transfer { border: 2px dotted gray; } 

JS:

$("#PMinfo").dialog({ 

    autoOpen: true, 
    height: 250, 
    width: 600, 
    modal: false, 
    draggable: false, 
    resizable: false, 
    beforeClose: function() { 

     var $this = $(this); 

     $this 
      .dialog("widget") 
      .effect("transfer", { 

       to: "#smpb_info_btn", 
       className: "ui-effects-transfer" 

      }, 500, function() { 

       $this.remove(); 

      }); 

    } 

}); 
+0

也許試試'beforeClose'事件 - 讓它看起來不那麼脫節:) – Jimbo 2013-07-22 08:28:04

+0

謝謝Jimbo,這是很順暢的。我已經更新了小提琴和答案。 – 2013-07-22 13:05:23