Results 1 to 8 of 8

Thread: Adding on click to the Panel

  1. #1

    Default Adding on click to the Panel

    The panel does not become clickable . Instead this runs just before the panel gets rendered.
    Please tell the fundamental issue I am commiting .

    HTML Code:
    <html>
    <head>
    <title>Hello World Window</title>
    <link rel="stylesheet" type="text/css" href="lib/ext/resources/css/ext-all.css" />
    <script type="text/javascript" src="lib/ext/adapter/ext/ext-base.js"></script>
    <script type="text/javascript" src="lib/ext/ext-all.js"></script>
    </head>
    <body>
    <script type="text/javascript">
    
     Ext.onReady(function() {
              
        var myPanel = new Ext.Panel({
            width       : 600,
            height      : 650,
            title       : 'Ext Panels rock!',
            collapsible : true,
            
            html        : '<div>' + 'My first Toolbar Panel!' + '</div>'
        });
                myPanel.on('click',alert("muhahahahaha"));
                var panel = new Ext.Panel({
                    id:'main-panel',
                    baseCls:'x-plain',
                    renderTo: Ext.getBody(),
                    layout:'table',
                    layoutConfig: {columns:3},
                    // applied to child components
                    defaults: {frame:true, width:200, height: 200},
                    items:[{
                        title:'Item 1'
                    },{
                        title:'Item 2'
                    },{
                        xtype: 'button'
                    },{
                        title:'Item 4',
                        width:410,
                        colspan:2,
                        hidden: true
                    },{
                        title:'Item 5'
                    },{
                        title:'Item 6'
                    },
                    myPanel,
                    {
                        title:'Item 7',
                        width:410,
                        colspan:2
                    },{
                        title:'Item 8'
                    }
                    
                    
                    
                    ]
                });
            });
    
    </script> 
    <div id='div1'>asdf</div>
    </body>
    </html>

  2. #2
    Sencha User Screamy's Avatar
    Join Date
    Jun 2008
    Posts
    244

    Default

    According to the API docs, an Ext.Panel doesn't support a 'click' event. I looked all the way up the inheritance chain and didn't find a click event either.

    Since it's not a recognized event for a panel, I'm guessing that myPanel.on() is falling on through and executing the alert().

  3. #3

    Default

    Then how do we add a custom event for click to Ext.Panel ?

  4. #4
    Sencha User laurentParis's Avatar
    Join Date
    Aug 2010
    Location
    paris
    Posts
    246

    Default

    Code:
    ...
    var panel = new Ext.Panel({
        id:'main-panel',
        ...
    });
    myPanel.el.on('click',function () {alert("muhahahahaha");});
    ...

  5. #5

    Default [SOLVED] Thanks


  6. #6

    Default

    Is there a way to do this as a listener?

  7. #7
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    Code:
    listeners: {
      render: function(c){
        c.getEl().on({
          click: function(e, t) {
            // code here
          }
        }, c);
      }
    }

  8. #8

    Default

    Nice, thanks!

Similar Threads

  1. not adding new row at click event
    By anoop abbot in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 24 Apr 2009, 6:48 AM
  2. Problem adding click even to TreePanel
    By vijaykiran in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 14 Aug 2008, 5:40 AM
  3. hyperlinks and adding click event??
    By Westside in forum Ext 2.x: Help & Discussion
    Replies: 6
    Last Post: 29 May 2008, 10:02 PM
  4. Please help!!!....Adding a textarea on click of a button
    By nandh_raj in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 10 Feb 2008, 8:24 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •