Jquery使用传输效果进行反向对话

时间:2015-01-30 13:04:27

标签: jquery effects transfer jquery-dialog

我正在寻找开放性和开放性关闭具有传输效果的jquery对话框,我得到了很好的写作。当点击登录按钮时,会出现带有传输效果的对话框,但我希望当对话框关闭时应该发生反向传输效果。我的反向传输效果代码无效。

<!DOCTYPE html>
<html>
<head>
<link href="//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.min.css" rel="stylesheet" type="text/css" />
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="//code.jquery.com/ui/1.11.2/jquery-ui.min.js"></script>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>

<a id="fill-login-form" href="#">Login</a>

<div id="login-form" style="display: none; width: 340px; height: 135px;">
    Some stuff
</div>

</body>
</html>

$(document).ready(function() {

    // turn the div into a jQuery UI dialog and hide it
    var dlg = $('#login-form').dialog({
        title: 'Just a cool dialog',
        autoOpen: false,
        // hook to the 'beforeclose' event instead of 'close'
        beforeclose: function(event, ui) {
            dlg.dialog('widget').effect('transfer', {
                to: '#fill-login-form',
                className: 'ui-effects-transfer'
            }, 500, null);
            return true; // to close it
        }
    });

    // open the dialog when the link is clicked
    $('#fill-login-form').click(function() {
        //Hide your dialog here
        dlg.dialog("open").dialog("widget").css("visibility", "hidden");
         $(this).effect("transfer", {
      to: dlg.dialog("widget"),
      className: "ui-effects-transfer"
  }, 500, function() {
           //Open the dialog after showing your transfer effect
      dlg.dialog("widget").css("visibility", "visible");
  });
    });

});

enter link description here

请修改代码以获得所需的效果。感谢

1 个答案:

答案 0 :(得分:1)

对于结束,to属性接收对象,而不是id字符串。因此它应该是$("#fill-login-form")而不是#fill-login-form

要开放,您的dlg作业应该更改。

以下是代码:

http://jsfiddle.net/Lss3hcgg/1/

相关问题