0

我正在尝试在模式中加载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>';

在 Infowindow 中,我可以设置内容并且可以正常显示,但是当我尝试使用 galleryView 时……它不再起作用。只是显示空白。

有什么建议么?

4

1 回答 1

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>

这是根据您的问题的更新答案

于 2015-03-03T16:41:23.237 回答