Skip to content

Instantly share code, notes, and snippets.

@mberman84
Created April 2, 2014 02:43
Show Gist options
  • Save mberman84/9927114 to your computer and use it in GitHub Desktop.
Save mberman84/9927114 to your computer and use it in GitHub Desktop.
: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