Ember Data Mockjax
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-mockjax/1.5.2/jquery.mockjax.js"></script>
<link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<script src="https://ember.alexspeller.com/canary/ember.debug.js"></script>
<script src="https://ember.alexspeller.com/canary/ember-template-compiler.js"></script>
<script src="https://ember.alexspeller.com/canary/ember-data.js"></script>
<script type="text/x-handlebars" data-template-name="application">
<h2>New Ember.js Query Params API: Arrays</h2>
<ul>
{{#each foo}}
<li>
{{this}}
<button {{action 'removeItem' this}}>Remove</button>
</li>
{{/each}}
</ul>
{{input value=text}}
<button {{action 'add'}}>Add</button>
<button {{action 'swap'}}>Swap Out Array</button>
</script>
CoffeeScript
App = Ember.Application.create()
App.ApplicationController = Ember.Controller.extend(
queryParams: [ 'foo' ]
foo: [
'ray'
'freakin'
'tiley'
]
saved: [ 'blorg' ]
actions:
removeItem: (i) ->
@foo.removeObject i.toString()
return
add: ->
@foo.pushObject @get('text')
@set 'text', ''
return
swap: ->
tmp = @saved
@set 'saved', @foo
@set 'foo', tmp
return
)