Results 1 to 3 of 3

Thread: How to use removeListener?

  1. #1
    Ext User dotnetCarpenter's Avatar
    Join Date
    Mar 2007
    Location
    Copenhagen, Denmark
    Posts
    271

    Default How to use removeListener?

    Can someone explain to me how the removeListener works?
    I have two buttons that works as previous and next navigation in a wizard made of tabs and at the last tab the next button changes to a save function. I want to remove that function when the user opens the wizard again but I don't understand what Function handler is.
    My code look something like this:
    Code:
    var btnNext = dialog.addButton(la_next, function(){
    	this.CurrentStep++;
    	tabs.getNextAvailable(this.CurrentStep).activate();
    	btnBack.enable();
    	if(this.CurrentStep == tabs.getCount())
    	{
    		btnNext.setText(la_save);
                    // add a new handler to save the gartered input
    		btnNext.on('click', function(){
    			dialog.hide();
    		}, dialog);
    	}
    }, this);
    dialog.addButton(la_close, dialog.hide, dialog);
    dialog.on('beforeshow', function(){
    	btnBack.disable();
    	if(btnNext.getText!=la_next)
    		btnNext.setText(la_next);
    	// remove the save function (if it's there)
    	btnNext.un('click', dialog.hide(), dialog); // what should I put as the second argument?
    });
    Do I need to put a named function in my click eventhandler and then remove it by giving the un function a that name?

    Thanks in advance!

  2. #2
    Ext User dotnetCarpenter's Avatar
    Join Date
    Mar 2007
    Location
    Copenhagen, Denmark
    Posts
    271

    Default

    I should check my question before I ask next time... It works with a named function. Is this the correct way of doing it?

  3. #3
    Sencha User
    Join Date
    Mar 2007
    Posts
    7,854

    Default

    Do I need to put a named function in my click eventhandler and then remove it by giving the un function a that name?

    Thanks in advance!
    Yes you do - you can see examples of this in the source code.

Posting Permissions

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