jquery - overriding backbone js sync method to add xhr event listener -


sync: function(method,model,options){          options.beforesend = function(xhr,settings) {              settings.xhr = function() {                   console.log('test');              }          }           return backbone.sync(method,model,options);     } 

i implement progress bar model fetch, , have added code above override sync access xhr method. however, doesn't seem fire or anything. i'm using jquery 2.0.3 , backbone 1.1.2

edit:

the problem have updateprogress fire once @ end.

options.beforesend = function(xhr,settings) {              settings.xhr = function() {                   var xhr = $.ajaxsettings.xhr();                  xhr.addeventlistener("progress", updateprogress, false);                    function updateprogress(event){                     console.log('loaded:'+event.loaded+' total:'+event.total);                     math.ceil(event.loaded/event.total*100);                 }                    return xhr;              };            } 


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -