Skip to content

Instantly share code, notes, and snippets.

@addieljuarez
Created October 30, 2014 01:36
Show Gist options
  • Select an option

  • Save addieljuarez/ae14872f99a2b8505ed5 to your computer and use it in GitHub Desktop.

Select an option

Save addieljuarez/ae14872f99a2b8505ed5 to your computer and use it in GitHub Desktop.
ejemplo FireEvent and EventListener
$.index.open();
$.botonNuevaVentana.addEventListener('click', function(e){
var ventana2 = Alloy.createController('ventana2').getView();
ventana2.open();
});
Titanium.App.addEventListener('cambioDeTexto', function(e){
// alert(e);
$.labelTexto.text = e.valor;
});
'.container':{
backgroundColor:'pink',
layout:'vertical'
}
'#botonNuevaVentana':{
top:50,
height:40,
width:150,
title:'nueva ventana',
borderColor:'#000',
}
'#labelTexto':{
top:30,
color:'#000',
text:'texto de la primera ventana',
}
<Alloy>
<Window class="container">
<Button id="botonNuevaVentana"></Button>
<Label id="labelTexto"></Label>
</Window>
</Alloy>
var args = arguments[0] || {};
$.buttonLanzador.addEventListener('click', function(e){
Titanium.App.fireEvent('cambioDeTexto',{'valor' : $.inputSegundaVentana.value});
});
".container" : {
backgroundColor:'blue',
opacity:0.4,
}
'#buttonLanzador':{
bottom:50,
height:50,
width:150,
title:'botton Lanzador',
borderColor:'#000',
}
'#inputSegundaVentana':{
bottom:120,
height:40,
width:200,
hintText:'inserta un texto',
borderColor:'#000',
}
<Alloy>
<Window class="container">
<TextField id="inputSegundaVentana"></TextField>
<Button id="buttonLanzador"></Button>
</Window>
</Alloy>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment