我正在尝试在模态中加载galleryView但它似乎没有工作。
使用galleryView本身似乎很好。我知道以前曾问过这个问题,但我找不到其他帖子的解决方案。
任何人在模态中都有一个可行的galleryView示例吗?
编辑:
content += "<a href='#openModal'>Pictures</a>";
$(function(){
$('#myGallery').galleryView();
});
content += '<div id="openModal" class="modalDialog">'+
'<div id="dialog">'+
'<a href="#close" title="Close" class="close">X</a>'+
'<h3>'+place.name+'</h3>'+
'<p>'+place.formatted_address+'</p>';
content += "<ul id='myGallery'>";
//Loop for thumbnail
for (var i = 0; i < place.photos.length; i++) {
thumbnail = place.photos[i].getUrl({'maxWidth': 88, 'maxHeight': 88});
content += "<li><img src='"+thumbnail+"' alt='"+place.name+"'/>";
}
content += "</ul>";
content += '</div></div>';
Inside Infowindow我能够设置内容,我可以很好地显示,但是当我注意使用galleryView时......它已经不再有效了。只是显示空白。
有什么建议吗?
答案 0 :(得分:0)
这是加载galleryview的简单对话框代码,我测试了它的工作
<script type="text/javascript">
var place = {name:"first name ", formatted_address:"street address line 1"};
place.photos = [{url:"http://www.spaceforaname.com/galleryview/img/photos/bp1.jpg",name:"Lone Tree Yellowstone"},{url:"http://www.spaceforaname.com/galleryview/img/photos/bp2.jpg",name:"Is He Still There?!"},{url:"http://www.spaceforaname.com/galleryview/img/photos/bp4.jpg",name:"Noni Nectar For Green Gecko"},{url:"http://www.spaceforaname.com/galleryview/img/photos/bp7.jpg",name:"Flight of an Eagle Owl"}];
var content = "<a href='#openModal'>Pictures</a>";
content += '<div id="openModal" class="modalDialog" style="display:none">'+
'<div id="dialog">'+
'<a href="#close" title="Close" class="close">X</a>'+
'<h3>'+place.name+'</h3>'+
'<p>'+place.formatted_address+'</p>';
content += "<ul id='myGallery'>";
//Loop for thumbnail
for (var i = 0; i < place.photos.length; i++) {
thumbnail = place.photos[i].url;
content += "<li><img src='"+thumbnail+"' alt='"+place.photos[i].name+"'/>";
}
content += "</ul>";
content += '</div></div>';
$(function(){
$( "#triggerdialog" ).on( "click", function() {
$('#model-wrapper').html(content);
});
$("body").on("click","a[href='#openModal']", function() {
console.log("model click");
$('#myGallery').galleryView();
$("#dialog" ).dialog();
});
});
</script>
<body>
<button id="triggerdialog">Load Content</button>
<div id="model-wrapper" />
</body>
以下是根据您的问题更新的答案