Hybrid View

  1. #1
    Sencha User
    Join Date
    Jul 2007
    Location
    Italy
    Posts
    134
    Vote Rating
    0
    fermo111 is on a distinguished road

      0  

    Default Cannot fire click event on Ext.Button

    Cannot fire click event on Ext.Button


    I am trying to fire a click event on a button whose handler was given in the config object.
    This is the code. My goal is to have the handler of the second button called in response of a click on the first button. But it does not work.

    Code:
    <div id='fire-btn'></div>
    <div id='event-btn'></div>
    
    Ext.onReady(function(){
    	fireBtn = new Ext.Button({
    		renderTo: 'fire-btn',
    		text: 'Fire click event',
    		handler: function(){
    			eventBtn.fireEvent('click');
    		}
    	});
    	eventBtn = new Ext.Button({
    		renderTo: 'event-btn',
    		text: 'Event Btn',
    		handler: function(){
    			alert('ok');
    		}
    	});
    });
    Thanks

    Luca

  2. #2
    Ext User santosh.rajan's Avatar
    Join Date
    Sep 2007
    Location
    Kannur, Kerala, India
    Posts
    611
    Vote Rating
    0
    santosh.rajan is on a distinguished road

      0  

    Default


    Define "var eventBtn = ..."
    Make everything as simple as possible, but not simpler.
    - Albert Einstein

  3. #3
    Sencha User
    Join Date
    Jul 2007
    Location
    Italy
    Posts
    134
    Vote Rating
    0
    fermo111 is on a distinguished road

      0  

    Default


    Quote Originally Posted by santosh.rajan View Post
    Define "var eventBtn = ..."
    That is not the reason. I think it has to do with the fact that the 'handler' function is not registered as an event handler for the 'click' event on the Ext.Button

  4. #4
    Ext User santosh.rajan's Avatar
    Join Date
    Sep 2007
    Location
    Kannur, Kerala, India
    Posts
    611
    Vote Rating
    0
    santosh.rajan is on a distinguished road

      0  

    Default


    You are right. This works.

    Code:
     listeners: {click: function() {alert("yep")}},
    Make everything as simple as possible, but not simpler.
    - Albert Einstein

  5. #5
    Sencha User
    Join Date
    Jul 2007
    Location
    Italy
    Posts
    134
    Vote Rating
    0
    fermo111 is on a distinguished road

      0  

    Default


    Quote Originally Posted by santosh.rajan View Post
    You are right. This works.

    Code:
     listeners: {click: function() {alert("yep")}},
    Right. So either this is a bug or the documentation is misleading. Any comment from the Ext developers?

  6. #6
    Sencha User
    Join Date
    Mar 2007
    Posts
    7,854
    Vote Rating
    4
    tryanDLS is on a distinguished road

      0  

    Default


    Not sure what you think the problem is - the following code works.
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
        <title>Hello World Window Example</title>
        <link rel="stylesheet" type="text/css" href="../../resources/css/ext-all.css" />
     	<script type="text/javascript" src="../../adapter/ext/ext-base.js"></script>
        <script type="text/javascript" src="../../ext-all.js"></script>
    <script text="text/javascript">
    Ext.onReady(function(){
        var button = new Ext.Button({
    		renderTo:'test',
    		text:'Hello',
    		handler: function() {
    			alert('hello');
    		}
    	});
    });
    </script>
    </head>
    <body>
    <div id="test"></div>
    </body>
    </html>

Thread Participants: 2