在我的应用程序中,我在仪表板上有一个巨大的地图,在加载ajax内容时,我会在那里放置标记。每个标记都专门设计了信息框,其中我有一个有两个类的链接:
在mouseover上,我期望工具提示被打开,而在mouseout上,我希望它被关闭,在单击时,我希望看到三件事情:
问题是,在mouseover和mouseout上,工具提示按预期工作,但当我单击链接时,信息框关闭,fancybox打开,但工具提示没有关闭,它松开父连接,从不关闭。
这是我的密码:
var infowindow_options = {
content: '...<a class="bind_tooltip">...</a>...',
disableAutoPan: false,
maxWidth: 0,
alignBottom: true,
pixelOffset: new google.maps.Size( 10, 10 ),
zIndex: null,
boxClass: 'info_window',
closeBoxMargin: '10px 10px 0 0',
closeBoxURL: 'http://www.google.com/intl/en_us/mapfiles/close.gif',
pane: 'floatPane',
enableEventPropagation: true,
infoBoxClearance: '10px',
position: mrkr.position
};
google.maps.event.addListener( mrkr, 'click', function() {
infowindow ? infowindow.close() : '';
infowindow = new InfoBox( infowindow_options );
infowindow.open( map );
return false;
} );
google.maps.event.addListener( map, 'click', function() {
if( infowindow ) {
infowindow.close();
$( '.bind_tooltip' ).tooltip( 'close' );
}
return false;
} );
$( document ).tooltip( {
items: '.bind_tooltip',
content: function() {
return $( this ).parent().find( '.tooltip' ).html();
},
position: {my: 'left top+10', at: 'center center'}
} );此外,我还得到了以下错误:
错误:无法在初始化之前调用工具提示上的方法;试图调用方法“关闭”
发布于 2014-02-03 06:46:38
一开始初始化工具提示并不能解决我的问题。所以我就这样解决了这个问题。我在前面添加了一个代码块,当单击map时,infowinfow应该关闭。这就是为什么我失去了我的信息参考。所以移除自动关机解决了我的问题。
发布于 2014-02-02 05:32:13
在脚本中的其他地方使用工具提示之前先初始化它。你最好在剧本开始的时候做。
var infowindow_options = {
content: '...<a class="bind_tooltip">...</a>...',
disableAutoPan: false,
maxWidth: 0,
alignBottom: true,
pixelOffset: new google.maps.Size( 10, 10 ),
zIndex: null,
boxClass: 'info_window',
closeBoxMargin: '10px 10px 0 0',
closeBoxURL: 'http://www.google.com/intl/en_us/mapfiles/close.gif',
pane: 'floatPane',
enableEventPropagation: true,
infoBoxClearance: '10px',
position: mrkr.position
};
google.maps.event.addListener( mrkr, 'click', function() {
infowindow ? infowindow.close() : '';
infowindow = new InfoBox( infowindow_options );
infowindow.open( map );
return false;
} );
$( document ).tooltip( {
items: '.bind_tooltip',
content: function() {
return $( this ).parent().find( '.tooltip' ).html();
},
position: {my: 'left top+10', at: 'center center'}
} );
google.maps.event.addListener( map, 'click', function() {
if( infowindow ) {
infowindow.close();
$( '.bind_tooltip' ).tooltip( 'close' );
}
return false;
} );https://stackoverflow.com/questions/20840626
复制相似问题