0

before i use jquery 1.10.x, jquery ui 1.10.x and prime ui 1.1.

for prime ui, there is a dialog widget, its usage like:

    jQuery('#div1').puidialog({  
            ...         
            modal: true,  
            width: 600
            ....           
        });

then when jQuery('#div1').puidialog('show'); is called, there is a dialog pop up and show this div.

However, after I upgrade jquery to 3.4.1 and jquery ui to 1.12.1, call jQuery('#div1').puidialog('show'); cannot show the dialog, there is no errors on console just say JQMIGRATE: jQuery.isWindow() is deprecated.

After debug, i found the problem happened in next code of primeui-1.1.js:

      _initPosition: function() {
            //reset
            this.element.css({left:0,top:0});
           
            if(/(center|left|top|right|bottom)/.test(this.options.location)) {
                this.options.location = this.options.location.replace(',', ' ');

                this.element.position({
                            my: 'center',
                            at: this.options.location,
                            collision: 'fit',
                            of: window,
                            //make sure dialog stays in viewport
                            using: function(pos) {
                                var l = pos.left < 0 ? 0 : pos.left,
                                t = pos.top < 0 ? 0 : pos.top;
                                
                                jQuery(this).css({
                                    left: l,
                                    top: t                                  
                                });
                            }
                        });
            }
            else {
                var coords = this.options.position.split(','),
                x = coords[0].trim(),
                y = coords[1].trim();

                this.element.offset({
                    left: x,
                    top: y
                });
            }

            this.positionInitialized = true;
        }

if i remove of: window from this.element.position({...}), the dialog can be shown, but this dialog is located at left top.

that is, after i upgrad jquery from 1.10.x to 3.4.1, this primeui dialog cannot be shown. and if i delete of: window from this.element.position({...}), this primeui dialog will be shown on left top.

what i want is this dialog located on center of browser, how can i do that?

frank
  • 1,169
  • 18
  • 43

0 Answers0