我使用鈦合金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