Removing a view's EventListener without removing the view ?

poq2011's Avatar

poq2011

06 Apr, 2013 05:12 PM

Hi all,

I have a view in my app and its mediator, everything works fine when starting the application

My view has a 'visible' property, in the application, because I sometimes need to hide it.

When the 'visible' property is set to false, it also removes all the EventListeners added at the view's instanciation.

The problem is that, by doing so, when setting the 'visible' property back to true, the mediator doesn't react anymore ! !

What should be the way to handle such a case?

  1. Support Staff 1 Posted by Shaun Smith on 06 Apr, 2013 06:30 PM

    Shaun Smith's Avatar

    Hi,

    Setting a visible to false on a view should not destroy that view's mediator. Are you using any other frameworks/libraries?

  2. 2 Posted by poq2011 on 06 Apr, 2013 10:20 PM

    poq2011's Avatar

    In my view, I have overridden the setter of the visible property to remove the event listeners ( by using the removeEventListener method) when visible is set to false. I did this to gain performance (since the view is not visible, the listeners are not usefull)

    When visible is set to true I re-enable the listeners by calling the addEventListemer.

    However, doing this breaks the link with the mediator. How can I force the view listeners to 'pause' when the view is not visible?

  3. Support Staff 3 Posted by Shaun Smith on 07 Apr, 2013 12:48 AM

    Shaun Smith's Avatar

    However, doing this breaks the link with the mediator

    I'm not quite sure what you mean by this. Could you explain a bit more? Also:

    In my view, I have overridden the setter of the visible property to remove the event listeners

    Are these internal listeners (internal to the view) or do they somehow relate to the mediator?

  4. 4 Posted by poq2011 on 07 Apr, 2013 02:16 PM

    poq2011's Avatar

    Indeed, setting a visible to false on a view doesn't destroy that view's mediator.

    It seems that my problem is coming from the fact that I have a several instances of the same View.

    I'm closing this discussion to open a new one on mediator and multiple instances of view.

  5. poq2011 closed this discussion on 07 Apr, 2013 02:16 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac