Skip to content

Instantly share code, notes, and snippets.

@visoft
Created June 19, 2014 22:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save visoft/17351e8aec895294b0e6 to your computer and use it in GitHub Desktop.
Save visoft/17351e8aec895294b0e6 to your computer and use it in GitHub Desktop.
Ember Delete Button Component

Ember Delete Button Component

Using Zurb Foundation and Font Awesome, I came up with a delete button that changes to a confirmation button. If you confirm, the delete goes through, otherwise if you move your mouse off the button, it resets back to just a normal delete button.

A Pen by Damien White on CodePen.

License.

<script type="text/x-handlebars">
{{{outlet}}}
</script>
<script type="text/x-handlebars" data-template-name="index">
<div class="container">
<p>Example Delete Button</p>
{{ delete-button }}
</div>
</script>
window.App = Ember.Application.create()
App.DeleteButtonComponent = Ember.Component.extend
tagName: 'button'
classNames: ['button', 'radius']
classNameBindings: ['alert']
attributeBindings: ['title']
layout: Ember.Handlebars.compile('<i {{bind-attr class=":fa icon"}}></i>')
alert: false
icon: 'fa-trash-o'
click: ->
if @get('alert')
alert 'delete'
return
@set 'alert', true
@set 'icon', 'fa-question-circle'
mouseLeave: ->
@set 'alert', false
@set 'icon', 'fa-trash-o'
title: (->
return "Delete this item." unless @get('alert')
"Are you sure you want to delete this item?"
).property('alert')
@import "compass/css3";
.container {
padding: 30px
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment