2014-04-23 4 views
0

에서 Spin.js을 중지하는 방법 나는 나가있는 jqGrid에 spin.js 블록의 UI를 구현해야 내 작품에 실제로다른 JS 파일

를 도움이 필요합니다. 이 코드는 동일한 파일 및 함수에 넣을 때 괜찮습니다.하지만 다른 JS 파일에서 메서드를 호출하고 내 문제가있는 곳을 듣고 싶습니다. spin.js 및 블록 UI가 시작된 다음 차단 해제로 UI 중지를 차단하지만 spin.js는 계속 실행됩니다. BeforeRequest에서

() gridComplete() 나는 다른 메소드를 호출에있는 jqGrid 내가 전화 한 방법

$.pui.common.loaderAnimationON("pane-content"); 

이 방법이이 코드

loaderAnimationON: function (div) { 
     var opts = { 
      lines: 13, // The number of lines to draw 
      length: 20, // The length of each line 
      width: 10, // The line thickness 
      radius: 30, // The radius of the inner circle 
      corners: 1, // Corner roundness (0..1) 
      rotate: 0, // The rotation offset 
      direction: 1, // 1: clockwise, -1: counterclockwise 
      color: '#000', // #rgb or #rrggbb or array of colors 
      speed: 1, // Rounds per second 
      trail: 60, // Afterglow percentage 
      shadow: false, // Whether to render a shadow 
      hwaccel: false, // Whether to use hardware acceleration 
      className: 'spinner', // The CSS class to assign to the spinner 
      zIndex: 2e9, // The z-index (defaults to 2000000000) 
      top: '50%', // Top position relative to parent in px 
      left: '50%' // Left position relative to parent in px 
     }; 
     var target = document.getElementById(div); 
     var spinner = new Spinner(opts).spin(target); 


     $.blockUI({ 
      blockMsgClass: "gridProjectsLoader", 
      message: null 
     }); 

     return spinner; 
    }, 

에서 : 여기

내 코드입니다

 $.pui.common.loaderAnimationOFF("pane-content"); 

이 코드에는이 코드가 있습니다

 loaderAnimationOFF: function (div) { 
     var target = document.getElementById(div); 
     var spinner = $.pui.common.loaderAnimationON(); 
     spinner.stop(target); 
     $.unblockUI(); 
    } 

누구든지 나를 도와 줄 수 있습니까?

감사합니다.

답변

1

동일한 개체를 사용하여 시작하고 중지해야합니다. 어디에서나 전역 변수를 사용할 수 있습니다. (그냥 .js) jsFiddle을 확인하십시오. 그것은 3 초 후에 회 전자를 멈춘다.

http://jsfiddle.net/YX7dy/8/

spinner=loaderAnimationON('Spin'); 
setInterval(function(){spinner.stop();},3000);