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

Button组件onclick事件无法阻止默认浏览器行为 #7

Open
mytharcher opened this issue Jun 28, 2012 · 2 comments
Open

Button组件onclick事件无法阻止默认浏览器行为 #7

mytharcher opened this issue Jun 28, 2012 · 2 comments
Assignees
Labels

Comments

@mytharcher
Copy link
Collaborator

Button.js中的代码:

if ( !me.isDisabled() ) {
    me.onclick();
}

onclick事件不能通过return false来阻止默认行为,如果是一个submit按钮,那么点击后表单仍会提交。

另外,css里在disabled状态下按钮上鼠标仍是手型。

@ghost ghost assigned leeight Jul 2, 2012
@leeight
Copy link
Collaborator

leeight commented Jul 2, 2012

fixed

@leeight leeight closed this as completed Jul 2, 2012
@mytharcher mytharcher reopened this Jul 2, 2012
@mytharcher
Copy link
Collaborator Author

没有彻底修复,不过应该是另一个问题,但应该合并考虑。

原因是Button设置禁用时并没有吧主元素main设置HTML的原生禁用状态,导致表单仍然会提交。

两种修复方案:

  1. 在现有基础上先不考虑真实禁用状态(但迟早是问题),对判断禁用后采取同样的措施preventDefault;

    if ( me.isDisabled() || false === me.onclick() ) {
        baidu.event.preventDefault(e || window.event);
    }
    
  2. 解决掉禁用状态,使之彻底不可点;

各位考虑。

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

No branches or pull requests

2 participants