Skip to content

Instantly share code, notes, and snippets.

@h6w
Created September 7, 2016 04:17
Show Gist options
  • Save h6w/db7cd56f626f2647f24f18c288e2218b to your computer and use it in GitHub Desktop.
Save h6w/db7cd56f626f2647f24f18c288e2218b to your computer and use it in GitHub Desktop.
fastn select bloat?
fastn('picker', {
options: [
{
something: '5 minutes',
someKey: '00:00:05:00'
},
{
something: '1 hour',
someKey: '00:01:00:00'
},
{
something: '4 hours',
someKey: '00:04:00:00'
},
{
something: '1 day',
someKey: '01:00:00:00'
},
{
something: '1 week',
someKey: '07:00:00:00'
}
],
itemTemplate: function(model, scope, select, renderItem){
var item = renderItem(model.get('item.something'));
item.on('click', select);
return item;
},
currentTemplate: function(model){
var selectedValue = model.get('item.something');
return crel('div', selectedValue ? 'You picked ' + model.get('item.something') : 'Pick a value');
},
id: 'duration',
value: '00:00:05:00',
onchange: 'value:value'
})
@h6w
Copy link
Author

h6w commented Sep 7, 2016

Ahah! This looks much better:

 fastn('list:select', {
                      id: 'duration',
                      value: '00:00:05:00',
                      onchange: 'value:value',
                      items: [ 
                        { value: '00:00:05:00', name: '5 minutes' },
                        { value: '00:01:00:00', name: '1 hour' },
                        { value: '00:04:00:00', name: '4 hours' },
                        { value: '01:00:00:00', name: '1 day' },
                        { value: '07:00:00:00', name: '1 week' }
                      ],
                      template: function() {
                        return fastn('option', { value: fastn.binding('item.value') }, fastn.binding('item.name') )
                      }
                    }
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment