Answer the question
In order to leave comments, you need to log in
JS Stack of events on the page
I have a page on which a bunch of blocks should be updated almost in real time (I saw a photo > after 20 seconds it changes to > I saw a photo and left a comment > after 2 hours > I left the site).
The easiest way is to make separate requests for each part of the page, but this is expensive. There was an idea to make a request every 5 seconds to query the server about events and set a Callback for certain data:
var handlerUrl = '/data/events';
var listen = new Listen(handlerUrl, 5);
listen.on('tape', 'create', function(item){
$('...').append(item.content);
});
listen.on('tape', 'update', function(id, item){
$(id).html(item.content);
});
listen.on('tape', 'remove', function(id, item){
$(id).remove();
});
Answer the question
In order to leave comments, you need to log in
You can use Backbone.js. To change the model, hang up events that will redraw the page. And download the model from the server at a specified frequency.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question