Titanium JavaScript:如何将数据/值从一个窗口传递到另一个窗口 [英] Titanium JavaScript: How to pass data/values from one window to another window
本文介绍了Titanium JavaScript:如何将数据/值从一个窗口传递到另一个窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在目标c中,我们可以很容易地通过nextClassname.recievedVariable = passedVariable;
In objective c we can pass data between two classes very easily by nextClassname.recievedVariable = passedVariable;
我尝试了同样的钛,但失败的数据
i tried same with titanium, but failed
我尝试如下
第二类
$.table.addEventListener('click', function(e) {
var selected = e.row;
alert(e.row.title);
var TodayStatus = Titanium.UI.createWindow({ url:'TodayStatus.js' });
TodayStatus.seletedProj = e.row.title;
// var TodayStatus = new Alloy.createController("TodayStatus");
TodayStatus.getView().open();
});
在第一个Calss中,我们必须从另一个类接收字符串
in the first Calss whic we have to recieve string from another class
var win = Ti.UI.currentWindow;
Ti.API.info(win.seletedProj);
但会导致类似
message = "'undefined' is not an object (evaluating 'win.seletedProj')";
[ERROR] : name = TypeError;
推荐答案
您可以通过传递这样的参数来传递数据。
You can pass the data by passing parameter like this.
x.addEVentListener('click', function(e){
var controller = require('controllerPath').createWindow(e.value);
controller.open();
})
并且在controller.js
And in controller.js
exports.createWindow = function(value)
{
//whatever You like to do with UI
}
这篇关于Titanium JavaScript:如何将数据/值从一个窗口传递到另一个窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文