Created
April 24, 2012 23:31
-
-
Save euforic/2484573 to your computer and use it in GitHub Desktop.
Easy Evented Titanium Forms With Shimmy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Requires [Shimmy](https://github.com/Xogix/TiLibrary/tree/master/Shimmy) | |
//Simple forms with Shimmy | |
var shimmy = require('/Shimmy') | |
, ui = shimmy.UI | |
, _ = shimmy._; | |
var win = ui.Window(); | |
var form = ui.Form({ | |
style: 'grouped' //Set Form/Table Style | |
, fields: [ //Input type defaults to textfield | |
{ name: 'Title', section: 'title', hint: 'Event Name', value: '', id:'title' } | |
, { name: 'Start', section: 'duration', hint: 'Start Time', value: '' } | |
, { name: 'End', section: 'duration', hint: 'End Time', value: '' } | |
, { name: 'Repeat', section: 'duration', hint: 'Repeat', value: '' } | |
, { name: 'Notes', section: 'notes', hint: 'Additional Notes', value: '', type:'textarea' } | |
] | |
}); | |
// Input Event Listeners | |
form.on('Title.focus', function(e){ alert(e.source); }); | |
form.on('Title.change', function(e){ alert(e.source); }); | |
form.on('Title.blur', function(e){ alert(e.source); }); | |
// Access Individual Form Fields | |
// Field Accessors default to name value if no id is set | |
form.fields.title.value = 'newvalue'; | |
// Batch updates of Form Fields and other field attributes | |
form.setValues({Title:{ value:'Awesome', data:'HIDDENDATA'} }); | |
//Toggle Ability to Edit Form Fields | |
form.editable(false); | |
// Form input Event Listeners | |
form.on('title.focus', function(e){ alert(e.source); }); | |
form.on('Start.change', function(e){ alert(e.source); }); | |
form.on('Repeat.blur', function(e){ alert(e.source); }); | |
// Form Table Proxy Event Listeners | |
form.onProxy('click', function(e) { | |
// Get Form Values | |
var formVals = form.getValues(); | |
alert(formVals); | |
}); | |
win.add(form); | |
win.open(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment