I have a view consisting differebt surfaces and I want my app to close this view and display another view by clicking a button on the first view,l but I dont know how to close thi first view
this is my code:
var Engine = require('famous/core/Engine');
var Surface = require('famous/core/Surface');
var View = require('famous/core/View');
var mainContext = Engine.createContext();
var myView = new View();
var SecondView=new View();
mainContext.add(myView);
var surface = new Surface({
size: [100, 100],
content: 'click me',
properties: {
color: 'white',
textAlign: 'center',
backgroundColor: '#FA5C4F'
}
});
var surface2= new Surface({
content:'hi',
size:[100,100],
properties:{
backgroundColor:'pink'
}
});
myView.add(surface);
SecondView.add(surface2);
surface.pipe(myView);
surface.on('click',function(){
mainContext.add(SecondView)
});
surface2.on('click',function(){
mainContext.add(myView)
});
now, it works for the first time! it goes from myView to Second view, and then it will come back, but if you click the surface for the second time it wont work! i feel like i should remove the myView and then display SecondView for it to work but I dunno how!