Skip to content

Instantly share code, notes, and snippets.

@apcomplete
Created March 27, 2014 17:33
Show Gist options
  • Save apcomplete/9813274 to your computer and use it in GitHub Desktop.
Save apcomplete/9813274 to your computer and use it in GitHub Desktop.
Ember easyForm array input using Zurb Foundation
Ember.EasyForm.ArrayInput = Ember.View.extend
classNames: ["row"]
templateName: 'easyForm/array_input'
valueItems: (->
@get('value').map (item) ->
{ value: item }
).property()
valueItemsDidChange: (->
@set('value', @get('valueItems').getEach('value'))
).observes('[email protected]')
actions:
addItem: ->
@get('valueItems').pushObject({ value: '' })
removeItem: (item) ->
@get('valueItems').removeObject(item)
Ember.EasyForm.Config.registerInputType('array', Ember.EasyForm.ArrayInput)
{{#each item in view.valueItems}}
<div class="large-11 columns">
{{ input-field item.value }}
</div>
<div class="large-1 columns">
<a {{ action "removeItem" item class="postfix" target='view' }}>
&times;
</a>
</div>
{{/each}}
<div class="large-12 columns">
<a {{ action "addItem" target='view' }}>
<i class="icon-plus"></i>
</a>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment