如果屏幕高度小于Dialog高度,Dialog的top会是负数,可以写一类继承dijit.Dialog 然后把fix写在里面
dojo.provide("company.Dialog");
dojo.require("dijit.Dialog");
/**
* fix the same issue from the dijit.Dialog
*/
dojo.declare("company.Dialog", [dijit.Dialog],{
/**
* @see dijit.Dialog#postCreate
*/
postCreate: function() {
this.inherited(arguments);
this.connect(this, "_position", "_fixPosition");
},
/**
* fix the position while the dialog size is less than the browser screen
*/
_fixPosition: function() {
var mb = dojo._getMarginSize(this.domNode),
viewport = dojo.window.getBox();
if (viewport.h < mb.h) {
var top = dojo.style(this.domNode, 'top');
if (top < 0) {
dojo.style(this.domNode, {top: '0'});
}
}
}