2013-04-24 43 views
7

Tôi đang sử dụng tệp javascript có tên là pull.js. Nó được sử dụng cho làm mới kéo xuống trong Ipad nhưng, khi tôi sử dụng jquery khác và javascript ngừng làm việc? Nó được đưa ra các lỗi ngoại lệ còn tự do sau:Lỗi Javascript không được ngoại lệ

" Error: uncaught exception:

[Exception... "Not enough arguments" nsresult: "0x80570001 (NS_ERROR_XPC_NOT_ENOUGH_ARGS)" location: "JS frame :: pull.js :: anonymous :: line 26" data: no] "

Tôi đi qua các nội dung này js file:

var PULL = function() { 
    var content, 
     pullToRefresh, 
     refreshing, 
     contentStartY, 
     success, 
     start, 
     cancel, 
     startY, 
     track = false, 
     refresh = false; 

    var removeTransition = function() { 
     //content.style['-webkit-transition-duration'] = 0; 
    }; 
    return { 
     init: function(o) { 
      content = document.getElementById('content'); 
      pullToRefresh = document.getElementById('pull_to_refresh'); 
      refreshing = document.getElementById('refreshing'); 
      success = o.success; 
      start = o.start; 
      cancel = o.cancel; 

      document.body.addEventListener('touchstart', function(e) { 
       e.preventDefault(); 
       contentStartY = parseInt(content.style.top); 
       startY = e.touches[0].screenY; 
      }); 

      document.body.addEventListener('touchend', function(e) { 
       if(refresh) { 
        //content.style['-webkit-transition-duration'] = '.5s'; 
        content.style.top = '50px'; 

        pullToRefresh.style.display = 'none'; 
        refreshing.style.display = ''; 

        success(function() { // pass down done callback 
         pullToRefresh.style.display = ''; 
         refreshing.style.display = 'none'; 
         content.style.top = '0'; 
         content.addEventListener('transitionEnd', removeTransition); 
        }); 

        refresh = false; 
       } else if(track) { 
        //content.style['-webkit-transition-duration'] = '.25s'; 
        content.style.top = '0'; 
        content.addEventListener('transitionEnd', removeTransition); 

        cancel(); 
       } 
       track = false; 
      }); 

      document.body.addEventListener('touchmove', function(e) { 
       var move_to = contentStartY - (startY - e.changedTouches[0].screenY); 
       if(move_to > 0) track = true; // start tracking if near the top 
       content.style.top = move_to + 'px'; 

       if(move_to > 50) { 
        refresh = true; 
       } else { 
        //content.style['-webkit-transition'] = ''; 
        refresh = false; 
       } 
      }); 
     } 
    }; 
}(); 

bất cứ ai có thể vui lòng giúp tôi.

+1

Bạn đang thiếu tham số radix trên phương thức parseInt của mình. – lifetimes

+0

@ user125697 radix là tùy chọn paramneter – 999k

+0

số dòng là gì 26 –

Trả lời

5

lỗi XPC không đến từ cách gọi một phương pháp Javascript tinh khiết như parseInt (và đối số radix tùy chọn bằng cách đặc điểm kỹ thuật, vì vậy tất cả những bình luận sai trên nhiều đếm).


Bạn đang missing the third useCapture argument trên tất cả các addEventListener bạn gọi:

đây:

document.body.addEventListener('touchstart', function(e) { 
    ... 
}, false); //<-- add third argument 

đây:

content.addEventListener('transitionEnd', removeTransition, false); //<-- add third argument 

đây:

document.body.addEventListener('touchend', function(e) { 
    ... 
}, false); //<-- add third argument 

đây:

content.addEventListener('transitionEnd', removeTransition, false); //<-- add third argument 

Và ở đây:

document.body.addEventListener('touchmove', function(e) { 
    ... 
}, false); //<-- add third argument 

Lưu ý rằng trong một newer specification, the argument has been made optional. Nhưng điều đó không thực sự quan trọng.

Các vấn đề liên quan