具体原因是因为bootstrap的弹是出窗口是用DIV来实现的.一开始该DIV是display:none的.点击按扭时将该弹出框进行居中显示.所以这里就会有个问题: button.offset();该方法获取不到button.offset().left坐标.一直是0;因为DIV如果是display:none的话,根据就不会有坐标.所示点击"请选择图片"按扭无任何反应.而在DIV最靠左边是可以点击的(因为left=0)打开OS的文件选择对话框的.
refresh: function() {
var shimContainer = this.getRuntime().getContainer(),
button = this.options.button,
width = button.outerWidth ?
button.outerWidth() : button.width(),
height = button.outerHeight ?
button.outerHeight() : button.height(),
pos = button.offset();
debugger;
width && height && shimContainer.css({
bottom: 'auto',
right: 'auto',
width: width + 'px',
height:height + 'px'
}).offset( pos );
},
通过浏览器的调试发现:id = rt_rt_1a9hrgustle51qf4dft1prs1d4f1的DIV为真正的打开OS选择文件对话框的焦点.该焦点并未与"请选择图片"的按扭重合(因为该DIV的CSS STYLE的left值为0).原因也就是因为这段HTML代码是放在bootstrap的一个DIV为display:none下导致的,导致在计算button.offset()时获取坐标时值为0;
请选择图片
而button.offset()计算正确的话id=rt_rt_1a9hrgustle51qf4dft1prs1d4f1的DIV样式中left值应该如下:
请帮助分析一下,如果项目中必须基于在HTML文档初始化过程中DIV是display:none时,然后点击按扭再显示的,有无解决方案能够也支持.
谢谢