javascript - Ember Application Alerts -
i have application following application , view. want able flash these notifications during various points in application. current emberscripts file includes
class candidate.applicationcontroller extends ember.arraycontroller alerts: ember.object.create success: [ 'tada!' 'here go!' ] error: [ 'what did now!?' ] candidate.alertsview = ember.view.extend templatename: 'views/alerts' candidate.alertview = ember.view.extend templatename: 'views/alert' class: (-> return 'alert alert-' + @type ).property() close: -> @$().slideup 'normal', => @destroy()
and handlebars view/alerts
looks this:
{{#each alerts.success}} {{view candidate.alertview messagebinding=this type="success"}} {{/each}}
and views/alert
:
<div {{bindattr class="view.class" }}> <i class="icon-remove-sign"></i> <button type="button" class="close" {{action 'close' target='view'}}>×</button> {{view.message}} </div>
right works fine initialized value, has few issues.
- it not allow me add new alerts
- the close function not remove alert alerts object on application controller
how go making this bit closer session flash alert message bag available on server?
here's jsbin of current code: http://jsbin.com/ejas/1/
you can @ example using ember component http://jsbin.com/aquqili/8/edit?html,js,output hope may you
Comments
Post a Comment