Three ways to use button with event
There are three ways to use button with event. Following are three samples.
/**
* The first way to use button with event: default event is "onclick".
*
*
*/
<script type="text/javascript">
Ext.onReady(function(){
new Ext.Button([
renderTo: Ext.getBody(),
text: "Confirm",
handler: function(){
alert("Welcome to ExtJS world!");
}
]);
});
</script>
/**
* The second way to use button with event.
*/
<script type="text/javascript">
Ext.onReady(function(){
new Ext.Button([
renderTo: Ext.getBody(),
text: "Confirm",
listeners: {
"click": function(){
alert("Welcome to ExtJS world!");
}
}
]);
});
</script>
/**
* The third way to use button with event.
*/
<script type="text/javascript">
Ext.onReady(function(){
var _button = new Ext.Button([
renderTo: Ext.getBody(),
text: "Confirm"
]);
_button.on("click", function(){
alert("Welcome to ExtJS world!");
});
});
</script>