diff options
Diffstat (limited to 'javascripts')
-rw-r--r-- | javascripts/dashing.coffee | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/javascripts/dashing.coffee b/javascripts/dashing.coffee index e5875d8..20a9987 100644 --- a/javascripts/dashing.coffee +++ b/javascripts/dashing.coffee @@ -40,7 +40,6 @@ class Dashing.Widget extends Batman.View @mixin($(@node).data()) Dashing.widgets[@id] ||= [] Dashing.widgets[@id].push(@) - @mixin(Dashing.lastEvents[@id]) # in case the events from the server came before the widget was rendered type = Batman.Filters.dashize(@view) $(@node).addClass("widget widget-#{type} #{@id}") @@ -55,6 +54,12 @@ class Dashing.Widget extends Batman.View @::on 'ready', -> Dashing.Widget.fire 'ready' + # In case the events from the server came before the widget was rendered + lastData = Dashing.lastEvents[@id] + if lastData + @mixin(lastData) + @onData(lastData) + receiveData: (data) => @mixin(data) @onData(data) @@ -109,8 +114,8 @@ source.addEventListener 'message', (e) -> if lastEvents[data.id]?.updatedAt != data.updatedAt if Dashing.debugMode console.log("Received data for #{data.id}", data) + lastEvents[data.id] = data if widgets[data.id]?.length > 0 - lastEvents[data.id] = data for widget in widgets[data.id] widget.receiveData(data) |