Created
April 2, 2014 02:43
-
-
Save mberman84/9927114 to your computer and use it in GitHub Desktop.
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
:javascript | |
var readyFunc = function() { | |
if(typeof(pubnub) == "undefined"){ | |
var pubnub = PUBNUB.init({ | |
subscribe_key : "#{CONFIG['pubnub_subscribe_key']}" | |
}) | |
} | |
pubnub.subscribe({ | |
channel : "#{@customer.channel}", | |
message : function(message){ | |
if(message.customer_id == #{@customer.id}){ | |
debugger; | |
$('#message').append($('<li>').text("#{@customer.first_name}" + ': (' + "#{Time.now.utc.to_s(:time)}" + ') '+ message.text)); | |
} | |
} | |
}); | |
}; | |
$(document).ready(function(readyFunc){ | |
console.log("running readyfunc from document.ready event handler"); | |
readyFunc(); | |
}); | |
$(document).on('page:load', function(readyFunc){ | |
console.log("running readyfunc from page:load event handler"); | |
readyFunc(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment