한 창에서 다른 창으로 데이터를 보내려고합니다.티타늄의 한 창에서 다른 창으로 데이터를 전달하는 방법은 무엇입니까?
예 : 첫 번째 창에는 텍스트 필드와 버튼이 있습니다. 창을 클릭하면 두 번째 창에 텍스트 필드 값을 보내야합니까?
튜토리얼을 발견했지만 MVC에 없습니다.
한 창에서 다른 창으로 데이터를 보내려고합니다.티타늄의 한 창에서 다른 창으로 데이터를 전달하는 방법은 무엇입니까?
예 : 첫 번째 창에는 텍스트 필드와 버튼이 있습니다. 창을 클릭하면 두 번째 창에 텍스트 필드 값을 보내야합니까?
튜토리얼을 발견했지만 MVC에 없습니다.
저는 새 합금 컨트롤러를 만들었습니다 (프로젝트에서 왼쪽 클릭 한 다음 새로 만들기). 다음은 매개 변수를 다음보기로 전달하는 방법입니다.
새 컨트롤러를 CallBack이라고하고 첫 번째 컨트롤러를 index라고합니다. CallBack.xml에서
난이 :
CallBack.tss에서<Alloy>
<View class="container">
</View>
</Alloy>
내가 가진 : CallBack.js에서
".container": {
backgroundColor: "black"
}
내가이 : 마지막으로
var args = arguments[0] || {};
//here you can do whatever you want to your parameter, i just show the value.
alert(args.textField);
와의를 index.js 이것은 내 textField의 매개 변수를 전달하는 방법입니다.
//with a button i can open a new view in my current window
$.btnNext.addEventListener('click',function(e){
//tfInsert is the id of my textfield in index.xml file and with .value i can access to whatever it contains
//the "?" operator is like an if
var textField = $.tfInsert.value != "" ? textField = $.tfInsert.value : textField = "Hello";
var nextView = Alloy.createController('/CallBack', {
textField: textField
}).getView();
//this is how i add a new view to my current window
$.window.add(nextView);
});
희망이 도움이됩니다. (우리가 데이터를 전달하는 곳에서) controller.js calledWindowController.js에서
function createController(win)
{
//title is the data to pass
var platform = Ti.Platform.osname;
var calledWindow = require('/ui/' + platform + '/addProductWindow').createCalledWindow(title);
calledWindow.open();
};
에서
function createController(win){
//Do whatever control you want
};
exports.createCalledWindow = function(title)
{
//Do whatever UI you want
Ti.include('/Controllers/calledWindowController.js');
var controller = createController(win);
return win;
};
이해할 수 없었습니다. 응답 파일 구조를 설명하거나 추가 할 수 있습니까? 대답은? – Machado
내가 사용하지 않아도 합금. 공통점을 사용하여 필요합니다 .js – user2648752