我使用钛合金MVC与需要扫描QR码 钛SDK 3.4.0.GA返回结果从另一个控制器钛合金
项目控制器我有2个控制器:index.js和secondwindow。 js和它们各自的视图index.xml和secondwindow.xml。 我要开始扫描并处理secondWindow控制器扫描的结果,而结果返回到索引控制器,让索引处理自己的UI元素
我试着像这样 INDEX.XML:
<Alloy>
<Window>
<Label id='result' />
...Other components...
<Button onClick='startScan'>Start QR scan</Button>
</Window>
</Alloy>
index.js:
function whenSecondWindowFinish(arg){
//update index.xml
$.result.setText(arg);
}
function startScan(e){
Alloy.createController('secondWindow');
}
$.index.open();
secondWindow.xml:
<Alloy>
<Window exitOnClose='false'>
</Window>
</Alloy>
secondWindow.js:
function scanOK(data){
var returnResult = /*Handle data*/
//I need to return the result to the index controller
$.secondWindow.close();//And close this view
}
function canceled(){
//return {} to index controller
$.secondWindow.close();//And close this view
}
var QRscanner = require('qrscanner');
var qroptions = {
//width height ...
success: scanOK,
cancel: canceled
};
var qrview = QRscanner.createQRView(qroptions);
$.secondWindow.add(qrview);
$.secondWindow.open();
我怎样才能成功关闭此窗口/取消功能,并将结果返回到索引控制器或通知索引执行whenSecondWindowFinish扫描(/ 通ARG结果 /);方法?或者哪种方法是正确的?
我了解的是你想从'secondWindow.js'发送一些结果'index.js'(对吗?)和你想发送的结果是什么类型(String,object,other)? – turtle 2014-11-06 03:32:15