【问题标题】:How to add images dynamically to grid in jquery mobile?如何在jquery mobile中将图像动态添加到网格中?
【发布时间】:2012-06-09 10:27:34
【问题描述】:

我想使用 jquery mobile 将图像动态添加到网格中。我遵循以下代码jQuery Mobile grid with images and captions。但是这里的图像是静态添加的。但是在我的项目中,我需要在运行时将图像添加到网格中,我不知道会有多少,所以我想动态添加它们。所以任何人都可以请建议我如何将图像动态添加到网格中。

我正在使用 android 中的 phonegap 插件实现此代码....

提前谢谢...

【问题讨论】:

    标签: jquery android jquery-plugins jquery-mobile cordova


    【解决方案1】:
    you should go through loop and append data to parent div..
    
    Ex:
    
        <div class ='ui-grid- c' id="parentDiv">
    
            </div>
    
        And your code;;
            var Items = [];
                for(var i=0;i< your_data_length:i++){
                   //Add your code here
            Items.push("<div class='ui-block-b'><img src="your image source"></div>");  
    
    
    
            }
             $('#perentDiv').append(Items.join(''));
             $('#perentDiv').trigger('create');
    
    
        if youcan post your data list , i can post more code ..
    

    /*这将用于 2 列网格。如果需要 maor 列网格,只需将 div 的类更改为http://jquerymobile.com/test/docs/content/content-grids.html 上的给定。

    【讨论】:

    • 实际上数据将从服务器上传,所以我现在只需要设置代码&当从服务器添加图片时,它们需要附加到网格...你能帮我解决这个问题吗... ...
    • 当然..您需要根据您给出的示例在循环中附加数据。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多