Created
July 20, 2015 19:06
-
-
Save Woody88/3c6495d25fcd84e8b036 to your computer and use it in GitHub Desktop.
Dispatcher at top level cannot be detect in PostWidget.coffee nor Dashbords.coffe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//TradeWidget.coffee | |
ready = -> | |
dispatcher = new WebSocketRails($('#TradWidgetWrapper').data('uri'), true) | |
dispatcher.on_open = (data) -> | |
console.log('Connection has been established: ', data); | |
channel = dispatcher.subscribe 'trades' | |
channel.bind 'new_trade_post', (message) -> | |
console.log(message) | |
$(document).ready(ready) | |
$(document).on('page:load', ready) | |
//PostWidget.coffee | |
ready = -> | |
## Posting Websocket functioning ## | |
dispatcher = new WebSocketRails($('#posting').data('uri'), true) | |
dispatcher.on_open = (data) -> | |
console.log('Connection has been established: ', data); | |
channel = dispatcher.subscribe 'posts' | |
channel.bind 'new_post', (message) -> | |
message.created_at = "less than a minute" | |
Posts.unshift('list', message).slideUp("slow") | |
send = (message) -> | |
dispatcher.trigger 'posting', message | |
$(document).ready(ready) | |
$(document).on('page:load', ready) | |
// Dashborads.coffee | |
#= require trade_widget | |
#= require post_widget | |
ready = -> | |
## New Posts ## | |
$('#new_post').on 'click', (e) -> | |
e.preventDefault() | |
send($('#message').val()) | |
$('#message').val('') | |
dispatcher = new WebSocketRails($('#posting').data('uri'), true) | |
dispatcher.on_open = (data) -> | |
console.log('Connection has been established: ', data); | |
channel = dispatcher.subscribe 'posts' | |
channel.bind 'new_post', (message) -> | |
console.log(message) | |
message.created_at = "less than a minute" | |
ractive.unshift('list', message) | |
send = (message) -> | |
dispatcher.trigger 'posting', message | |
$(document).ready(ready) | |
$(document).on('page:load', ready) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment