English 中文(简体)
管理与 jQuery 移动电话和电话机的动态列表
原标题:Managing dynamic lists with jQuery Mobile and Phonegap

我要从数据库中显示一个列表。 列表中的每个项目都与 ID 相关。 我想知道跟踪列表中每个项目的 ID 的最佳方式。 因此, 当我单击此项目时, 我可以用该 ID 来映射数据库中项目的其他属性 。

最佳回答

我不知道什么是“最佳方法”,但一个方法,你可以做到这一点,就是将id嵌入锚标签,然后用客户侧路由解决方案(请查看 backbone.js , 这样您就可以收藏一个代表每个项目的模型, 以及每个与 DOM 中某个元素连接的视图( 在您的情况中为 li), 并且可以窃听来回应该元素上的事件( 例如, 当您单击项目所看到的项目对点击事件做出响应并据此采取行动时 ) 。

< 强度 > 编辑 :

我个人一直在用骨干.js来构建我自己的代码, 如果您对它感兴趣的话, 您应该能找到许多教义。 总之, 这里有一个 < a href=" http://jsfidle. net/ kSMtp/" rel="nofollow" >jsfidle 的基本想法是使用骨干.js来维持对列表中每个项目的引用。 当然, 您也可以在 Vanilla JavaScript 中这样做 。

问题回答

暂无回答




相关问题
Javascript data store solution using PhoneGap

Does anyone have any experience of storing data in JavaScript across all mobile platforms using PhoneGap? My ideal solution would be to use something like SQLite, but unfortunately SQLite isn t ...

get image from iphone, using phonegap camera api

I m new to Xcode and iPhone apps. I want to select an image from iPhone (camera or library) and send to php via ajax. http://wiki.phonegap.com/iPhone:-Camera-API I m using the phonegap framework, ...

Getting Search Keyboard on iPhone using PhoneGap

I have created a search field on a mobile app i am creating via PhoneGap. I ve tried using with no luck. I also know that i could get around the visual aspect of the input field via CSS & ...

How can I detect a shake gesture in PhoneGap 0.8?

I m using PhoneGap 0.8 and I d like to detect a basic shake gesture. I ve found two relevant snippets: http://groups.google.com/group/phonegap/browse_thread/thread/25178468b8eb9e9f http://phonegap....

How do I fix PhoneGap build errors?

I am trying to build a PhoneGap-based iPhone application, but I keep getting the following two errors: ./build-phonegap.sh: line 6: ./configure: No such file or directory cp: lib/iphone/phonegap-min....

热门标签