Skip to content

Instantly share code, notes, and snippets.

@kamilbiela
Last active December 11, 2015 23:19
Show Gist options
  • Save kamilbiela/7e72bb2f532c171b1bf3 to your computer and use it in GitHub Desktop.
Save kamilbiela/7e72bb2f532c171b1bf3 to your computer and use it in GitHub Desktop.
{{outlet}}
<div class="container">
<div class="row">
<div class="span12">
<ul class="thumbnails thumbnails-list">
{{#each gallery in controller}}
{{#view App.GalleriesIndexItemView}}
<li class="span4">
<div class="thumbnail">
<a href="#">
<img src="images/300x200.gif" alt="">
</a>
<div class="caption">
<h4>{{gallery.name}}</h4>
{{#if view.hover}}
<button {{action editGallery gallery }} class="btn btn-mini" type="button">Edit</button>
<button {{action deleteGallery gallery}} class="btn btn-mini" type="button">Delete</button>
{{/if}}
</div>
</div>
</li>
{{/view}}
{{/each}}
</ul>
</div>
</div>
</div>
App.GalleriesIndexController = Ember.ArrayController.extend({
deleteGallery: function(gallery) {
if (confirm('Are You sure? You will delete all photos in ' + gallery.get('name') + ".")) {
gallery.deleteRecord();
App.store.commit();
}
},
editGallery: function(gallery) {
// todo
}
});
App.GalleriesIndexItemView = Ember.View.extend({
hover: false,
mouseEnter: function() {
this.set('hover', true);
},
mouseLeave: function() {
this.set('hover', false);
}
});
App.GalleriesIndexRoute = Ember.Route.extend({
enter: function() {
this.controllerFor('application').set('currentMenuItem', 'dashboard');
},
model: function() {
return App.Gallery.find();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment