首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >GwtQuery - fadeOut()之后的Widget空()

GwtQuery - fadeOut()之后的Widget空()
EN

Stack Overflow用户
提问于 2013-07-29 17:58:03
回答 1查看 164关注 0票数 0

出于对将引导带警报/通知库封装到GWT的失望,我决定使用GwtQuery制作一个:

代码语言:javascript
复制
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();
    }
}

这段代码的问题是,这个方法可能会被用户多次调用,因此append'ed HTML将随着时间的推移积累起来。空的,就像注释行中的那样,会导致通知甚至不出现。

什么是解决方案,使其消失后,它将清空通知面板?

更新

当我说:

( $(w).empty()在fadeIn()之前,在第二次调用该方法时,没有显示任何内容。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-08-19 07:50:34

当所有动画完成后,您必须排队一个函数以删除errorAlert

每次调用showErrorNotification方法时,都应该停止队列,以避免在完成之前多次调用队列时出现问题。

在添加errorAlert之前,您必须先删除它,以避免在上次通知被删除之前停止通知时重复。

代码语言:javascript
复制
    $(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();  
      }
    });
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17930945

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档