iteye_21250 2011-06-02 22:00
浏览 264
已采纳

ExtJS3.3.1 Button disabled后还可以提交?

有一段代码,放到extjs官网的论坛上,同时所以提到这里来:
同时也可以参考这里:http://www.sencha.com/forum/showthread.php?135592-button-disabled-and-submit-form-bug
[code="javascript"]


<!-- Ext.onReady(function () { var btn = new Ext.Button({ disabled: true, text: "start submit", type: "submit", renderTo: "j_id3:submit" }); btn.on("click", function(){alert('aa');}); }); //-->


[/code]

这段代码,执行的时候把form提交了,但是disabled已经设置true了,不想让它提交。
其实是这样的,在Ext3.3.1中有如下代码:
[code="javascript"]
// private
onClick : function(e){
if(e){
e.preventDefault();
}
if(e.button !== 0){
return;
}
if(!this.disabled){
this.doToggle();
if(this.menu && !this.hasVisibleMenu() && !this.ignoreNextClick){
this.showMenu();
}
this.fireEvent('click', this, e);
if(this.handler){
//this.el.removeClass('x-btn-over');
this.handler.call(this.scope || this, this, e);
}
}
},
[/code]

这个代码没有被调用到,而是直接调用了form的提交。而这点跟Ext2.0是不兼容的,在2.0里不会提交表格。

  • 写回答

2条回答

  • weixin_42317583 2011-06-07 17:35
    关注

    属性 type: "submit",跟 disabled已经设置true冲突,最好btn别使用type属性,如果有多个表单就要选择提交哪个表单

    想要提交表单,先取得表单对象,再手动提交

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥30 matlab解优化问题代码
  • ¥15 写论文,需要数据支撑
  • ¥15 identifier of an instance of 类 was altered from xx to xx错误
  • ¥100 反编译微信小游戏求指导
  • ¥15 docker模式webrtc-streamer 无法播放公网rtsp
  • ¥15 学不会递归,理解不了汉诺塔参数变化
  • ¥15 基于图神经网络的COVID-19药物筛选研究
  • ¥30 软件自定义无线电该怎样使用
  • ¥15 R语言mediation包做中介分析,直接效应和间接效应都很小,为什么?
  • ¥15 Jenkins+k8s部署slave节点offline