Guest User

Untitled

a guest
Jan 24th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. ...
  2.  
  3. var Server = Pusher.new('api_key', 'channel');
  4.  
  5. // option 1
  6.  
  7. Server.bind('event',function(data){
  8. console.log("data received");
  9. });
  10.  
  11. /* option 2
  12. Re Build your element
  13. */
  14.  
  15. Server.bind('event',function(data){
  16. var strong = $("<strong>",{
  17. text: data.user.name
  18. }),
  19.  
  20. link = $("<a>",{
  21. href:"#"
  22. });
  23.  
  24. link.append(strong);
  25. $("#box_"+data.app.name+"_app_"+data.name).html(link);
  26. });
  27.  
  28. /* Option 3
  29. Build on request.
  30. */
  31.  
  32. Server.bind('event',function(data){
  33. $(data.tag).html(data.html);
  34. });
  35.  
  36. ...
Add Comment
Please, Sign In to add comment