Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

能不能把已有的div弹出来? #65

Closed
zhishaofei3 opened this issue Jun 27, 2014 · 6 comments
Closed

能不能把已有的div弹出来? #65

zhishaofei3 opened this issue Jun 27, 2014 · 6 comments

Comments

@zhishaofei3
Copy link

能不能把已有的div弹出来?而不是通过content的形式

@popomore
Copy link
Member

Element 参数—
Sent from Mailbox for iPhone

On Fri, Jun 27, 2014 at 12:06 PM, zhishaofei notifications@github.com
wrote:

能不能把已有的div弹出来?而不是通过content的形式

Reply to this email directly or view it on GitHub:
#65

@afc163
Copy link
Member

afc163 commented Jun 27, 2014

content: '#elementId'

@zhishaofei3
Copy link
Author

放在页面下部的HTML,是我自己写的一个登录框:

<div class="popup login">
    <div class="header">
        <span class="close-wrapper">
            <span class="close">×</span>
        </span>
        <div class="tip">无需账号,直接使用合作账号登录</div>
        <div class="login-qq"></div>
    </div>
    <div class="content">
        <form action="#">
            <div class="username-wrapper">
                <label for="login-username">用户名:</label>
                <input type="text" id="login-username" required />
            </div>
            <div class="password-wrapper">
                <label for="login-password">密码:</label>
                <input type="password" id="login-password" required />
            </div>
            <label class="save-password-wrapper">
                <input type="checkbox" class="save-password">记住密码
            </label>
            <a class="forget" href="javascript:;">忘记密码</a>
            <button class="login-btn" type="submit"></button>
        </form>
        <div class="ljzc">
            没有账号, <a href="javascript:;">立即注册</a>
        </div>
    </div>
</div>

调用:

    loginDialog = new Dialog({
        content: ".login",
        closeTpl: ""
    });
    console.log(loginDialog.content);//undefined

页面中有.login 元素 ,但是content输出undefined,
所以我面临一个问题,就是我页面上的login如果一开始就display:none,
那么我调用loginDialog.show()的时候 login其实还是display:none的。
这样的话 我调用的时候就比较麻烦了,要用两句话搞定:

    $(".login").show();
    loginDialog.show();

我通过loginDialog取content又是undefined,所以不太明白怎么做了。

@afc163
Copy link
Member

afc163 commented Jun 27, 2014

loginDialog.content 是啥?为啥这么取?

loginDialog.get('content')

@zhishaofei3
Copy link
Author

loginDialog.get("content").show();
loginDialog.show();

哦!原来是我用错了。
我现在通过这两句话可以达到目的了,但是我能不能通过重写dialog的show方法,来让dialog自动把content display:block出来,而不是dialog已经show出来了,content却在display:none?

var Dialog = Dialog.extend({
    show: function() {
        Dialog.superclass.show.call(this);
        this.get("content").show();
    }
});

loginDialog.show();

明白了,谢谢大虾!!!

@afc163
Copy link
Member

afc163 commented Jun 27, 2014

loginDialog.before('show', function() {
  this.get("content").show();
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants