What is the best way to transfer data between windows using titanium (classic)?

'The code I've written utilizes MyHTTPlink to retrieve information such as Restaurant Name, url, and address. Currently, it lists all restaurant names and urls in a table. Now, I want to figure out how to send the details of a table row to the next window (.js page). Each restaurant's URL contains a list of menu items which I would like to display in a table row on the next page. How should I approach coding this?'.

var win = Titanium.UI.createWindow ({  backgorundColor: '#000'}); 

var tableview = Ti.UI.createTableView({ 
 height:'auto', 
 layout:'vertical', 
 top:5, 
 right:5, 
 bottom:5, left:5 });

var data = [];

var xhr = Ti.Network.createHTTPClient ({
onload: function () {

    alert("success!");
    var json = JSON.parse(this.responseText);
    for (var i = 0; i < json.connectionResponses.length; i++) {


        var row = Ti.UI.createTableViewRow({
            height: 60,
        });

        var restLabel = Ti.UI.createLabel({
            text: json.connectionResponses[i].restaurantName, 
            height: 'auto',
            left:54,
            top: 5,
            font:{ fontSize:20 } 
        });
        var connLabel = Ti.UI.createLabel({
            text: json.connectionResponses[i].connectingurl, 
            height: 'auto',
            left:54,
            bottom:5,
            font:{ fontSize:14 } 

        });
        var image = Titanium.UI.createImageView({ 
            image:'images/menu_icon.png',  
            top:4, 
            left:0, 
            height:45, 
            width:41 
        });

        row.add(restLabel);
        row.add(connLabel);
        row.add(image);
        data.push(row);
    }

    tableview.setData(data);

   },
   onerror: function () {
        alert('There was an error retrieving the remote data. Try again.');
   }
   //timeout:5000
   });

xhr.open("GET", "http:MYHTTPlink"); 
xhr.send();

tableview.addEventListener('click',function(e){
     //alert("RS Name : " +e.row.title);
     var winn = Ti.UI.createWindow({ url:'hotelpage.js'});
     winn.open();
    //var hostelwin = require('hotelpage').gethotelWin;
    //var newwin = new hotelwin();
    //newwin.open();
  });

   win.add(tableview);

   win.open();

Answer â„–1

Feel free to refer to the code snippet below and incorporate it into your project for optimal functionality:

tableview.addEventListener('click',function(e){
         //alert("RS Name : " +e.row.title);
         var winn = Ti.UI.createWindow({ 
             url:'hotelpage.js',
             row_title : e.row.title,
             all_info: e.row,
         });
         winn.open();
        //var hostelwin = require('hotelpage').gethotelWin;
        //var newwin = new hotelwin();
        //newwin.open();
      });

Additionally, make sure to include the following in your "hotelpage.js" file:

var curtWind = Ti.UI.currentWindow;
// Retrieve necessary data using the following method
var title = curtWind.row_title;
var allData = curtWind.all_info;
// Customize as needed based on your project requirements.

This should provide some valuable insights for your project needs.

Best regards,

Answer â„–2

Aside from the response provided by MRT which is accurate and functional, you have the option to utilize this code that eliminates the need for the url property according to recommendations found in the Titanium 3.X documentation.

Your code snippet:

tableview.addEventListener('click',function(e){
    hotelWin = require('/yourpath/hotelpage');
    var hotelW = new hotelWin(e.row.title, e.row.id)
  });

Content of hotelpage.js file:

function external(title, id) {
    var hotelPageWin = Titanium.UI.createWindow({
    //properties go here
    });

    //Within this function, you can access two variables: 
    //title has been assigned the value of e.row.title
    //id has been assigned the value of e.row.id

    hotelPageWin.open();

    return hotelPageWin;
};

module.exports = external;

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The Enigma of AngularJS Coding

Check out this code snippet. $scope.$watch('year', reloadData); $scope.$watch('month', reloadData); $scope.year = 2017; $scope.month = 1; var reloadData = function() { /* Refresh Data */ } var init = function() { $scope.year ...

The mapDispatchToProps function is failing to work, throwing an error: Uncaught TypeError: _this.props.addCountdown is not a function

Currently, I am facing an issue while working on my first app. The problem arises with a form component that should send an object via an onSubmit handler. onSubmit = (e) => { e.preventDefault(); this.props.onSubmit({ title: ...

Having issues sorting the ranking table numerically in a Javascript/jQuery/JSON/localStorage game

I have successfully created a leaderboard for my game, but I am struggling to automatically sort the scores from high to low. I believe that placing the objects into an array and then sorting them may be the solution, however, I am unsure of how to do th ...

What is the best way to distinguish a particular item in a <select> element and include a delete button for each row using jQuery?

1.) I've set up a nested table and now I want to ensure that when the 'Delete' button within the child table is clicked, its corresponding row gets deleted. 2.) I have a <select> tag. The issue is how can I implement validation to che ...

Make a call to a URL in Symfony2 with JavaScript (AJAX)

I have developed a Symfony2 RESTful webservice prototype that is still a work in progress. I am looking for guidance on how clients can send JSON data or consume JSON data from this webservice. Essentially, I need examples of how to send requests or post d ...

Show the helper text when a TextField is selected in Material UI

I would like the error message to only show up when a user clicks on the TextField. Here's my code: import React, { useState, useEffect } from 'react'; import { TextField, Grid, Button } from '@material-ui/core'; const ReplyToComm ...

Utilizing Angular: Integrating the Http response output into a map

I have a situation where I am making multiple HTTP calls simultaneously from my Angular application. The goal is to store the responses of these calls in a Map. data: Map<number, any> = new map<number,any>(); --------------------------------- ...

Is there a way to configure MaterialUI XGrid filters to target and filter by the renderCell parameters instead of the backend data source?

While utilizing MaterialUI XGrid to showcase rows of information, I am facing an issue with filtering. Currently, filtering can only be done based on the backend row values rather than what is displayed in the cell. For instance, consider a column named U ...

Changing the designated materialUI class

Within the project, I am utilizing this theme: export const theme = createMuiTheme({ ...defaultThemeConfig, overrides: { ...defaultThemeConfig.overrides, MuiListItem: { root: { '&:nth-child(odd)': { backgro ...

Place a checkbox at the start of each table cell

Is there a way to add a checkbox before the text in the first cell of each row in an HTML table using jQuery? I attempted this method: $("table td:first-child").each(function() { $(this).prepend('<input type="checkbox" class="basic-kpi-row"/&g ...

Transforming a single object into multiple arrays using AngularJS

Just starting out with AngularJS and I've got some data that looks like this { day1: 0, day2: 0, day3: 0, day4: 2 } Is there a way to convert this data into arrays structured like below? [     ["day1": 0],     ["day2": 0],   ...

Shorten certain text in Vuetify

Here's an example of a basic select component in Vuetify: <v-select :items="selectablePlaces" :label="$t('placeLabel')" v-model="placeId" required ></v-select> I'm looking to apply a specific style to all selec ...

Display only the selected index and conceal the rest

I am facing an issue where I have added a label and input in ng-repeat. The functionality works fine when the user clicks edit to show the input and hide the label. However, the problem arises when the user clicks on the new button as it displays the new i ...

Attempting to choose everything with the exception of a singular element using the not() function in Jquery

Within the mosaic (div #mosaique) are various div elements. My goal is to make it so that when I click on a specific div, like #langages or #libraries, the other divs become opaque while the selected div undergoes a size change (which works correctly in t ...

JavaScript regular expression for detecting valid characters without repeating a specific character

let rx = /(\/MxML\/[a-z0-9\[\]@/]*)/gi; let s = 'If (/MxML/trades[1]/value== 1 then /MxML/trades[type=2]/value must be /MxML/stream/pre/reference@href'; let m; let res = []; while ((m = rx.exec(s))) { res.push(m[1]); ...

Animated CSS Checkmark Design

How can I create an animated Check-mark using CSS with SVG animation? I attempted the following code but it doesn't seem to be working. Any suggestions? DEMO: https://jsfiddle.net/b7Ln0jns/ CSS: @import "bourbon"; $color--green: #7ac142; $curve: c ...

Using routes with optional parameters can inhibit the loading of other routes

In my Node.js app based on Express, I have implemented three different routes. app.get('/', function (req, res) { // }) app.get('/findOne', function (req, res) { // }) app.get('/getFour', function (req, res) { // }) Init ...

modifying the click state using a variable in jquery

Something feels off about my approach to this task. I currently have a series of hyperlinks, and when they are clicked, they go through a short sequence before changing states. When clicked again, they revert to their original state. var favourites = fun ...

A guide on triggering a function when the context changes in a React application

Can I automatically trigger a function in a component whenever the context changes? Specifically, I have a variable named isLoggedIn in the Navbar module. Whenever a user logs in, the value of isLoggedIn is updated to true. In my Blog module, how can I m ...

Tips for redirecting a page in React by forcing a route

Attempting to implement the guidance from this Stack Overflow solution on how to "go back home" after closing a Modal... import React, { Suspense, useState } from 'react'; import { BrowserRouter, Route, Switch, useHistory } from "react-route ...