backbone.js - why browser request for image after ajax? -


i'm using backbone , nodejs single page webapp.

i got view, has model(a blog post) in it. when user click on 'like' button, view start ajax send user'id server let number +1.

it looks this:

        this.model.save({             likedby: usermodel.get('_id')         }, {             url: '/posts/' + this.model.get('_id') + '/like',             success: function() {                 //             },             patch: true         }); 

my problem is, when code got run. browser start http request retrieve images on screen, , re-render them. screen got "shake" after user clicked button.

this not happening everywhere, caused this? how stop "shake"?

thanks advance.

when call this.model.save() model update data in server , call view's render function. render method create new dom element , replace old dom element, that's causing flickering (it requests images again).

i assume have api call action (if not it's better have one) can make sperate ajax call action on model adding function so:

addlike : function(data) {  backbone.ajax({             url: '/api/like/'+ this.get('id'),             method: 'post',             data: data,             success: options.success,             error: options.error         }); 

}


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -