Skip to content

Instantly share code, notes, and snippets.

@keithics
Created July 16, 2013 03:48
Show Gist options
  • Save keithics/6005606 to your computer and use it in GitHub Desktop.
Save keithics/6005606 to your computer and use it in GitHub Desktop.
Serialize text inputs using Titanium - works with inputs and textarea for now
_.mixin({
serialize:function(el){
var url = [];
_.map(el.getChildren(),function(value,key,el){
if(!_.isUndefined(value.name)){
url.push(value.name+ '=' + value.getValue());
}
});
return '?'+url.join('&');
}
});
/*
VIEW :: name to textfields are very important
<ScrollView id="scroller">
<TextField id="email" hintText="Email" class="margint10" name="email"></TextField>
<TextField id="password" hintText="Password" class="margint10" name="password"></TextField>
</ScrollView>
*/
urlencode = _($.scroller).serialize(); // ?email=&password=
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment