Skip to content

Instantly share code, notes, and snippets.

@jamesflorentino
Created September 28, 2013 12:04
Show Gist options
  • Save jamesflorentino/6741395 to your computer and use it in GitHub Desktop.
Save jamesflorentino/6741395 to your computer and use it in GitHub Desktop.
var App = Ember.Application.create();
App.ApplicationController = Ember.Controller.extend({
bag: ['Protein Shake', 'Training Shoes', 'Steroids', 'Insulin Shots'],
home: [],
actions: {
leaveAtHome: function(items) {
items.forEach(function(item) {
this.get('bag').removeObject(item);
this.get('home').addObject(item);
}.bind(this));
items.clear();
},
bringWithYou: function(items) {
items.forEach(function(item) {
this.get('home').removeObject(item);
this.get('bag').addObject(item);
}.bind(this));
items.clear();
}
}
});
<script type="text/x-handlebars" id="application">
<h2>Bring with you</h2>
{{view Ember.Select viewName="bag" contentBinding="bag" multiple="multiple"}}
<button {{action leaveAtHome view.bag.selection}}>Leave items at home, bro</button>
<hr>
<h2>Leave at home</h2>
{{view Ember.Select viewName="home" contentBinding="home" multiple="multiple"}}
<button {{action bringWithYou view.home.selection}}>DAFUQ, bro. Bring dat shit with you</button>
</script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.0.0/handlebars.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/ember.js/1.0.0/ember.min.js"></script>
<script src="app.js"></script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment