Ember Application Alerts
I currently have an application with the following application and view. I
want to be able to flash these notifications during various points in my
application. My current emberscripts file includes
class Candidate.ApplicationController extends Ember.ArrayController
alerts: Ember.Array.create
success: [
'TaDa!'
]
Candidate.NotificationView = Ember.View.extend
close: (type) ->
@$().slideUp 'normal', =>
@alerts.set type, null
templateName: 'views/alerts'
And my handlebars for the view looks like this:
<div class="alert alert-success">
<i class="icon-remove-sign"></i>
<button type="button" class="close" {{action 'close' 'success'
target='view'}}>×</button>
{{this}}
</div>
{{/each}}
Right now this works fine for the initialized value, but has a few issues.
It does not allow me to add new alerts
Hitting the close button closes all alerts at once
The close function does not remove the alert from the alerts object on the
application controller
How would I go about making this this a bit closer to a session flash
alert message bag like what would be available on the server?
No comments:
Post a Comment