var winAlert = Ti.UI.createWindow({}) var viewOpacity = Ti.UI.createView({ backgroundColor: "black", opacity: 0.7 }) winAlert.add( viewOpacity ) var viewAlert = Ti.UI.createImageView({ backgroundImage: "/imagens/alertDialog/bg.png", width: 250, height: 163 }) var botao1 = Ti.UI.createButton({ image: "/imagens/alertDialog/botao1.png", left: 10, bottom: 5 }) viewAlert.add(botao1) var labelSim = Ti.UI.createLabel({ font: {fontFamily:'Facebook Letter Faces',fontWeight:'bold', fontSize: 20 }, text: "Sim", color: "white", left: 40, bottom: 10 }) viewAlert.add(labelSim) var botao2 = Ti.UI.createButton({ image: "/imagens/alertDialog/botao2.png", title: "Nao", font: {fontFamily:'Facebook Letter Faces',fontWeight:'bold'}, right: 10, bottom: 5 }) viewAlert.add(botao2) var labelNao = Ti.UI.createLabel({ font: {fontFamily:'Facebook Letter Faces',fontWeight:'bold', fontSize: 20 }, text: "Não", color: "white", right: 40, bottom: 10 }) viewAlert.add(labelNao) var labelAlerta = Ti.UI.createLabel({ font: {fontFamily:'Facebook Letter Faces',fontWeight:'bold', fontSize: 20 }, text: "Você tem certeza?", color: "white", textAlign: "center", width: 230, top: 10 }) viewAlert.add(labelAlerta) var labelAlertaText = Ti.UI.createLabel({ font: {fontFamily:'Facebook Letter Faces',fontWeight:'normal', fontSize: 15 }, text: "Você está prestes a deletar a lista de favoritos.", color: "white", textAlign: "center", width: 230, top: 40 }) viewAlert.add(labelAlertaText) winAlert.add(viewAlert) winAlert.open() botao1.addEventListener( "click", function(){ //function of button1 winAlert.close() } ) botao2.addEventListener( "click", function(){ //function of button2 winAlert.close()this is the code that I have developed to make my custom alert dialog. my idea is to put this code in another. js and give an include in. js that I want to use this custom alert however, be able to change the text of the labels and the functions of the two buttons
anyone knows how to do this?
2 Answers
Accepted Answer
I wouldn't use include, use require instead. I just wrote a blog post about Reusable Components
If you use Ti.Include, then at runtime, you will essentially have one giant app.js loaded with all your code in it.
labelAlerta.text = 'my new text'; is an example of how you would make your label text changes in an event.
Your Answer
Think you can help? Login to answer this question!