I am wanting to move to another view and display the results from the previous view in that window. I cannot figure out how to achieve this.
My code in my app js is:
var SearchView = require('/ui/SearchView'); var ResultsView = require('/ui/ResultsView'); var MenuView = require('/ui/MenuView'); var AboutView = require('/ui/AboutView'); var search = new SearchView(); var results = new ResultsView(); var about = new AboutView(); // Each row with a view property when clicked will change to that view (any view works except tabgroups and windows) // If the row does not have a view property, but the switch event still fires var data = [ { title:'Search', hasDetail:true, view: search }, { title:'Results', hasDetail:true, view: results }, { title:'About', hasDetail:true, view: about } ]; var menu = new MenuView({ rowData: data });When I click search in menu i get sent to searchView which is:
var SearchView = function(args){ var self = Ti.UI.createView({ backgroundColor:'white' }); var results = new ResultsView(); var searchLabel = Ti.UI.createLabel({ font : { fontSize : 30, fontFamily : 'Helvetica Neue' }, top: 150, text: "Search" }); var searchField = Ti.UI.createTextField({ top:200, width: 200, borderStyle:Ti.UI.INPUT_BORDERSTYLE_ROUNDED, hintText: "Search", returnKeyType : Titanium.UI.RETURNKEY_SEARCH }); self.add(searchLabel); self.add(searchField); searchField.addEventListener('return', function(event) { var url = "http://xxxxxxx/xxxx/xxxxxxxxxxxx?search=" + event.value; var response = getSearch(url); }); function getSearch(url) { var client = Ti.Network.createHTTPClient({ // function called when the response data is available onload : function(e) { Ti.API.info("Received text: " + this.responseText); var jsonObj = JSON.parse(this.responseText); //slidingMenu.changeView(ResultsView); //getShow(jsonObj); }, // function called when an error occurs, including a timeout onerror : function(e) { Ti.API.debug(e.error); alert('error'); }, timeout : 5000 // in milliseconds }); // Prepare the connection. client.open("GET", url); // Send the request. client.send(); } return self; }; module.exports = SearchView;I am then wanting the focus to move to the results view and pass the JSON object to there too. Because of how this is programmed it must go the view and not create a new window.
Any Ideas? Thanks.
1 Answer
Accepted Answer
I dont really get your problem.... so you want to pass the JSON from search view to result view?... maybe if you just wait till you have your search´s JSON to create your "var ResultsView = require('/ui/ResultsView');" and then create a instance of that as "var rv=ResultsView(JSON object)"
Your Answer
Think you can help? Login to answer this question!