1. #1
    Ext User
    Join Date
    Mar 2007
    Posts
    54
    Vote Rating
    0
    bidyut is on a distinguished road

      0  

    Default Overriding closeClicked method

    Overriding closeClicked method


    i want to override the closeClicked method to hide the panel instead of removing it. I tried this code:
    Code:
    layout.add('center', new YAHOO.ext.ContentPanel('aPanel', {title: 'Panel 2', closable:true})).override({
    						closeClicked : function() {
    							alert("hello");
    						}
    					});
    But it does not throw the alert.

    Instead it still removes the panel.

    Is there anything wrong in the code?

    Thanks!

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

      0  

    Default


    Rather than trying to override the method, why don't you remove the closeBtn click listener and add your own to hide the panel

  3. #3
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,483
    Vote Rating
    35
    Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default Re: Overriding closeClicked method

    Re: Overriding closeClicked method


    Quote Originally Posted by bidyut
    i want to override the closeClicked method to hide the panel instead of removing it. I tried this code:
    Code:
    layout.add('center', new YAHOO.ext.ContentPanel('aPanel', {title: 'Panel 2', closable:true})).override({
    						closeClicked : function() {
    							alert("hello");
    						}
    					});
    But it does not throw the alert.

    Instead it still removes the panel.

    Is there anything wrong in the code?

    Thanks!

    I'm confused as to how this code is even running.

    ContentPanel does not have an override method. Do you have Firebug? You should see Javascript errors.

    To override a method in the Layout:

    Code:
    YAHOO.override(layout, { closeClicked:function(){alert("hello")}});
    Which would replace the method in the prototype. If you really wanted to do that.

  4. #4
    Ext User
    Join Date
    Mar 2007
    Posts
    54
    Vote Rating
    0
    bidyut is on a distinguished road

      0  

    Default


    Thanks. I am still learning But the code does run without any error. Firebug does not complain either. I wrote it that way after seeing a code snippet mentioned in this forum.

  5. #5
    Ext User
    Join Date
    Mar 2007
    Posts
    321
    Vote Rating
    0
    jbowman is on a distinguished road

      0  

    Default


    next step would be to throw it in a try/catch statement, as the error may not be being returned to the console.

  6. #6
    Ext User
    Join Date
    Mar 2007
    Posts
    54
    Vote Rating
    0
    bidyut is on a distinguished road

      0  

    Default


    I htink the most elgant way of adding a panel is using iframe instead of using div. But then i am learning this framework day by day. So I am much more comfortable using iframe and it is also cleaner.

  7. #7
    Sencha User genius551v's Avatar
    Join Date
    Mar 2007
    Posts
    287
    Vote Rating
    0
    genius551v is on a distinguished road

      0  

    Default sound fine....

    sound fine....


    tryanDLS, sound very interesting

    Quote Originally Posted by tryanDLS
    Rather than trying to override the method, why don't you remove the closeBtn click listener and add your own to hide the panel
    can you post some example of how do that?

    Tnks

  8. #8
    Sencha User jack.slocum's Avatar
    Join Date
    Mar 2007
    Location
    Tampa, FL
    Posts
    6,955
    Vote Rating
    16
    jack.slocum will become famous soon enough

      0  

    Default


    override() is added to every prototype and class that uses extendX.

    For example:

    Code:
    YAHOO.ext.LayoutRegion.override({
        someFunction : function(){
             ...
        }
    });
    That overrides someFunction on the prototype (for all LayoutRegions).

    You can also use it on individual objects:

    Code:
    var r = layout.getRegion('north'); // return LayoutRegion object
    r.override({
        someFunction : function(){
             ...
        }
    });
    This overrides someFunction on just that specific instance (not the prototype).

    The problem with your code is that closeClicked() is on the TabPanelItem, not the LayoutRegion. So overriding it on the region does nothing.

    What you are looking for is the event "beforeremove". You can use this event to cancel the remove and just hide the panel.

  9. #9
    Ext User
    Join Date
    Mar 2007
    Posts
    54
    Vote Rating
    0
    bidyut is on a distinguished road

      0  

    Default


    Jack, thanks for the response. Now the overriding part is more clear to me. I had that doubt from the beginning that I am not overriding the function at the right DOM level. And you confirmed it.

    However, using iframe solved my problem. Hiding and showing the panel would have worked, but in longer run it might have created more problem with browser holding up more memory and updating the panel appropriately with ajax data etc. But iframe solves many of those problem.

    While on this subject, is it possible to add mode buttons to the panel title bar. Currently if we set "closable: true", the close icon shows up. Is there a dom manipulation API or other helper API to add more buttons up there with functions attached to them?

    Thanks again for getting some time out to answer and clear my confusion.

  10. #10
    Sencha User jack.slocum's Avatar
    Join Date
    Mar 2007
    Location
    Tampa, FL
    Posts
    6,955
    Vote Rating
    16
    jack.slocum will become famous soon enough

      0  

    Default


    The region has a createTool method (private) that you can hack at. There is no public way to do this yet.

Similar Threads

  1. [Solved]Overriding onTriggerClick for ComboBox?
    By kjordan in forum Ext 2.x: Help & Discussion
    Replies: 14
    Last Post: 7 Jan 2008, 11:18 AM
  2. Grid reconfigure method
    By jeffiel in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 27 Mar 2007, 9:59 PM
  3. ColumnModel getColumns method
    By kalebwalton in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 22 Mar 2007, 5:48 AM
  4. Overriding a link
    By davedash in forum Ext 1.x: Help & Discussion
    Replies: 1
    Last Post: 17 Mar 2007, 4:38 PM
  5. Overriding or Extending the Ext.PagingToolbar
    By ericd in forum Ext 1.x: Help & Discussion
    Replies: 9
    Last Post: 2 Mar 2007, 7:45 AM

Thread Participants: 5

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar