从Gallery View插件中的url动态加载图像内容

我正在使用jQuery GalleryView插件在网页中显示图像。 图像是从xml中提供的url链接加载的,因为没有图像是随机的,我使用jQuery读取所有链接,然后validation然后要求GalleryView显示,但是看起来GalleryView没有响应动态创建但是如果我硬核HTML页面中的图像URL链接,然后它工作…我试图在Ajax的完成function中调用插件许多提前感谢…

galleryView插件url: http : //www.techrepublic.com/blog/webmaster/plug-in-galleryview-with-jquery-on-your-website/2079

//由jQuery生成的HTML代码—- //

// ——– jQuery的—–

  $(this).find('photo').each(function (index) { PropertyDetail.d_img_urlname[index] = $(this).find('urlname'); $("", { src: PropertyDetail.d_img_urlname[index].text(), error: function () { PropertyDetail.d_img_urlname.splice($.inArray(PropertyDetail.d_img_urlname[index]), 1); }, load: function (){ $("#selectedPropertyImg_Wrapper").find("#myGallery").append("
  • "); } }); });

    // GalleryView图像//

      ajax code.... }).done(function () { $(function () { $('#myGallery').galleryView({ panel_width: 750, panel_height: 500, frame_width: 100, frame_height: 67 }); }) }); 

    问题是,动态元素是在dom准备就绪后创建的,这就是为什么你的galleryView没有找到li标签以及图像的url。 使用单独的jquery插件,只读取和validationAjax函数中的图像的URL,同时确保此Ajax调用必须是async:false,以便在程序中进一步调用之前强制执行。 现在在你的document.ready中调用这个插件之前的其他函数和$(’#myGallery’)。galleryView。

     $.fn.initImages = function() { $.ajax({ type: https://stackoverflow.com/questions/17173595/loading-images-content-dynamically-from-url-in-gallery-view-plugin/"GEThttps://stackoverflow.com/questions/17173595/loading-images-content-dynamically-from-url-in-gallery-view-plugin/", url: https://stackoverflow.com/questions/17173595/loading-images-content-dynamically-from-url-in-gallery-view-plugin/"XMLFile.xmlhttps://stackoverflow.com/questions/17173595/loading-images-content-dynamically-from-url-in-gallery-view-plugin/", dataType: xml, async:false, success: function (xml) { //read images from url // validate images// // store valid urls in obj= a1// $(this).find('photo').each(function (index) { $(https://stackoverflow.com/questions/17173595/loading-images-content-dynamically-from-url-in-gallery-view-plugin/"#selectedPropertyImg_Wrapperhttps://stackoverflow.com/questions/17173595/loading-images-content-dynamically-from-url-in-gallery-view-plugin/").find(https://stackoverflow.com/questions/17173595/loading-images-content-dynamically-from-url-in-gallery-view-plugin/"#myGalleryhttps://stackoverflow.com/questions/17173595/loading-images-content-dynamically-from-url-in-gallery-view-plugin/").append(https://stackoverflow.com/questions/17173595/loading-images-content-dynamically-from-url-in-gallery-view-plugin/"
  • https://stackoverflow.com/questions/17173595/loading-images-content-dynamically-from-url-in-gallery-view-plugin/"); }); } }); }

    现在在你的html中调用galleryView插件函数之前的这个函数

      $(document).ready(function(){ $(this).initImages(); //call gallery now// $(function () { $('#myGallery').galleryView({ panel_width: 750, panel_height: 500, frame_width: 100, frame_height: 67 }); }) }); 
    Interesting Posts