【问题标题】:Dialog Updates in PrimefacesPrimefaces 中的对话框更新
【发布时间】:2012-10-17 13:56:51
【问题描述】:

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

真的没有办法在不重复实例的情况下以相同的方式执行此操作吗?重复的实例是怎么来的?难道只有当appendToBody 设置为 true 时才会发生这种情况,因为它被更新并再次转移到正文而不是仅仅被更新?

【问题讨论】:

    标签: jsf primefaces


    【解决方案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();
    }
    

    【讨论】:

    【解决方案2】:

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

    【讨论】:

      【解决方案3】:

      对于 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();
          }
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-09-06
        • 1970-01-01
        • 2012-05-26
        • 2015-08-02
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多