如何不点击
<button id="create" type="button">Create</butto>
而执行代码呢?Ext.onReady(function() {
var btn = Ext.get("create");
btn.on("click", function(){
btn.dom.disabled = true; // create the grid
var grid = new Ext.grid.TableGrid("the-table");
grid.render(); }, false, {single:true}); // run once
});
<button id="create" type="button">Create</butto>
而执行代码呢?Ext.onReady(function() {
var btn = Ext.get("create");
btn.on("click", function(){
btn.dom.disabled = true; // create the grid
var grid = new Ext.grid.TableGrid("the-table");
grid.render(); }, false, {single:true}); // run once
});
Ext.onReady里的内容是在页面加载的时候就执行了的,所以是不需要你点按钮的。但是你的click事件本来就是要点了之后才执行,所以
btn.on("click", function(){
btn.dom.disabled = true; // create the grid
var grid = new Ext.grid.TableGrid("the-table");
grid.render(); }, false, {single:true}); 这段代码是在你点击之后执行的。你如果需要不点击就执行,可以把这些写在另外一个方法里面,在页面加载的时候你调用一下就是。点击按钮也也调用就可以了