child view buttons
I have a window with a view in it. i add the buttons to the window to the main window on a double click :
win.addEventListener('doubletap', function(){
win.add(next);
win.add(done);
win.add(back);
win.add(home);
});
when i switch the views and the buttons stay displayed but i have a hid buttons method:
done.addEventListener('click', function(){
win.remove(next);
win.remove(done);
win.remove(back);
win.remove(home);
});
when this method is called the buttons are not brought back with a double click the event is in the window and the views are subclassed of the window so the even listener should still work or am i missing something
1 Answer
-
Your question is quite ambiguous, not least because you have missed out most of your code. Next time, formulate the most simple working code that demonstrates your issue and paste it to gist.
You are correct that once the buttons have been removed from the view/window, their events should not be fired. Although I can't tell for certain what your issue is, be aware that every doubletap event to the view will bubble to (will be passed to, and fire again) the window, so the buttons will continue to be added even when they are already visible. In your case, I don't think it matters because the underlying code will just add the same buttons with no discernible result to the user. That said, you should bear this in mind when developing, or it could have undesired results, depending on what you are doing.
Thus, it is better practice to store the state of the buttons (whether they have been added or removed). Take a look at this similar example from the KitchenSink.