2012-10-17 47 views
0

我在Primefaces论坛上读到,应该避免直接更新对话框或更新环绕元素,因为这些实例是重复的以及其他奇怪的行为。 但我们有一些特殊情况,并且确实需要更新包含大量对话框的元素。Primefaces中的对话框更新

是否真的没有办法以同样的方式做到这一点,而没有得到重复的实例?它是如何来到重复的实例?难道这只会发生在appendToBody被设置为true时,因为它被更新并且再次移动到身体而不是被更新?

回答

0

该对话框在v3.0中被重新实现。我认为现在没有问题。

1

解决的办法是修复dialog.js,请参阅Primefaces forum

对于Primefaces 3.4.1:

PrimeFaces.widget.Dialog.prototype._show = function() { 
    if(this.cfg.showEffect) { 
     var _self = this; 

     this.jq.show(this.cfg.showEffect, null, 'normal', function() { 
     _self.postShow(); 
    }); 
} 
else { 
    //display dialog 
    /*Begin Custom Code*/ 
    var dlg = jQuery(this.jqId); 

    if(dlg.size() > 1){ 
     dlg.last().remove(); 
    } 
    this.jq = dlg; 
    /*End Custom Code*/ 
    this.jq.show(); 

    this.postShow(); 
} 

this.focusFirstInput(); 
this.visible = true; 
this.moveToTop(); 

if(this.cfg.modal) 
this.enableModality(); 
} 
+0

对于Primefaces 2.2.1,你可以在dialog.js添加以下行(在第28行): 这.jq.removeAttr('id')。parent()。attr('id',this.id); 请参阅http://code.google.com/p/primefaces/issues/detail?id=1971 – cirmp

0

对于Primefaces 3.5

PrimeFaces.widget.Dialog.prototype._show = function() { 
    this.jq.removeClass("ui-overlay-hidden").addClass("ui-overlay-visible").css({display:"none",visibility:"visible"}); 

    if(this.cfg.showEffect){ 
     var a=this; 
     this.jq.show(this.cfg.showEffect,null,"normal",function(){ 
      a.postShow(); 
     }); 
    } 
    else { 
     //display dialog 
     /*Begin Custom Code*/ 
     var dlg = jQuery(this.jqId); 

     if(dlg.size() > 1){ 
      dlg.first().remove(); 
     } 
     this.jq = dlg; 
     /*End Custom Code*/ 
     this.jq.show(); 
     this.postShow(); 
    } 
    this.moveToTop(); 
    if(this.cfg.modal){ 
     this.enableModality(); 
    } 
}