javascript - 如何使用 phonegap 将数组值加载到 iPhone 应用程序中的 TableView 中

标签 javascript html cordova

我是 phonegap 的新手。现在我在我的 Lion mac 中使用 phonegap2.0。我的 xcode 版本是 4.3。现在我使用 html 为 iphone 应用程序创建了 Tableview。我使用 JavaScript 创建了包含一些值的数组。请查看下面的链接:在下面的链接中,我附上了我的 html 文件和我的 Javascript 文件。

"http://pastie.org/4779045"

现在我想在 TableView 中加载数组值。请一些人帮我加载完成这个问题。

最佳答案

这是一个示例代码

HTML 部分:

<!--HTML code -->
<ul data-role="listview" data-inset="true" id="lstMyList">
</ul>

Javascript

/*javascript code*/
var i;
var names= new Array();
names[0] = "Gopi";
names[1] = "Vinoth";
names[2] = "Yuvaraj";

for (i=0;i<names.length;i++){
    $('#lstMyList').append('<li><a href="#">'+names[i]+'</a></li>');//append list items to the list view dynamically 
}
//If you add items to a listview, you'll need to call the refresh() method on it to update the styles and create any nested lists that are added.
$('#lstMyList').listview("refresh");

希望你清楚。

关于javascript - 如何使用 phonegap 将数组值加载到 iPhone 应用程序中的 TableView 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12542630/

相关文章:

javascript - 在单选按钮检查上显示 div

javascript - 当函数和选择器不在一起时使用 "this"

javascript - 当另一个 div 滚出屏幕时显示一个 div。获得不需要的闪光

html - 如何使用图像作为表单中的选项

angularjs - 使用 ionic 应用程序内的系统浏览器打开所有链接

javascript - XMLHttpRequest.responseStream 在哪里定义的?

php - html2canvas 输出选定的div PHP

html - 如何确保可折叠表格后面的文本显示在其下方,而不是右侧?

javascript - Cordova js 仅在特定设备上的 Android 上返回错误的日期时间和 utc

javascript - 使用 Framework7 和 AngularJS 加载页面