2013-07-29 6 views
1

나는 GwtQuery 사용을하기로 결정했습니다GwtQuery은 - 빈() 위젯 페이드 아웃() 후 GWT에 부트 스트랩 경고/알림 라이브러리를 포장에 내 좌절의

public static void showErrorNotification(String message){ 
    List<Widget> allNotifications = $(".notification").widgets(); 
    for (Widget w : allNotifications){ 
     $(w).fadeIn(1000); 
     $(w).append("<div id=\"errorAlert\" class=\"rounded10 errorAlert\">" + 
       "<img alt=\"\" src=\"public/images/exclamation.png\"> " + 
       "You must accept the terms and conditions to finish your registration." + 
       "</div>"); 
     $(w).fadeOut(5000); 
     //$(w).empty(); 
    } 
} 

이 코드의 문제는이다 ,이 메소드는 사용자가 여러 번 호출 할 수 있으므로 시간이 지남에 따라 HTML이 누적됩니다. 주석 처리 된 행에서와 같이 비어 있으면 알림이 표시되지 않습니다.

해결책이 될 수 있으므로 페이드 아웃 한 후에 알림 패널이 비워집니다.

업데이트 :

내가 넣어

:

$(w).empty() 아무것도 fadeIn() 전에이 메소드가 불려 두 번째 시간을 보여줍니다.

답변

0

모든 애니메이션이 끝나면 errorAlert을 제거하는 기능을 대기열에 넣어야합니다.

showErrorNotification 메서드를 호출 할 때마다 큐를 중지해야만 완료되기 전에 여러 번 호출 될 때 문제가 발생하지 않습니다.

그리고 마지막 통지가 제거되기 전에 중단 된 경우에 반복되지 않도록 추가하기 전에 errorAlert을 제거해야합니다.

$(w).stop(true, true); 
    $(w).find(".errorAlert").remove(); 
    $(w).append("<div id=\"errorAlert\" class=\"rounded10 errorAlert\">" + 
     "<img alt=\"\" src=\"public/images/exclamation.png\"> " + 
     "You must accept the terms and conditions to finish your registration." + 
     "</div>"); 
    $(w).fadeIn(1000); 
    $(w).fadeOut(5000); 
    $(w).queue(new Function(){ 
     public void f() { 
     $(this).find(".errorAlert").remove(); 
     } 
    }); 
관련 문제