I need to delete the current view in the same view ... if I'm in the parent view, I can do
parentView.remove(childView);
but being in a child view, I donβt have a parentView , so how can I post a childView to get the parentView from above, since this happens when I press the back button in iOS? please, help
Here is my childView file.
function DetailView(){ var self = Ti.UI.createView({ backgroundColor:'#fff' }); // Create a Button. var aButton = Ti.UI.createButton({ title : 'aButton', height : '50', width : '100', top : '10', left : '20' }); // Listen for click events. aButton.addEventListener('click', function() { alert('\'aButton\' was clicked!');
I need to go back to pressing aButton, what should I do here to do this
}); // Add to the parent view. self.add(aButton); return(self); } module.exports = DetailView;
Here is my parental view:
//FirstView Component Constructor var self = Ti.UI.createView(); function FirstView() { //create object instance, a parasitic subclass of Observable var DetailView = require('ui/common/DetailView'); var data = [{title:"Row 1"},{title:"Row 2"}]; var table = Titanium.UI.createTableView({ data:data }); table.addEventListener('click', rowSelected); self.add(table); return self; } function rowSelected() { var DetailView = require('ui/common/DetailView'); //construct UI var detailView = new DetailView(); self.add(detailView); } module.exports = FirstView;
source share