开发者

jQuery Mobile Listview - list item onClick never fires in Android Emulator

In a jQuery Mobile listview, I have a series of items:

<ul data-role="listview" id="lv_systems" data-inset="true">
  <li><a href="#page2" data-id="sys1">System 1</a></li>
  <li><a href="#page2" data-id="sys2">System 2</a></li>
    ....
</ul>

In the $(document).ready(), I add a click handlers to each <a> like 开发者_如何学Cthis (suggested here) (#select_system is the page name):

$(document).ready( function () {         

$('#select_system').live ('pagecreate', function(){
    $('#lv_systems').delegate('li', 'click', function(){
             alert('list item clicked');
    });
});
    $('#lv_systems').listview('refresh');
});

Testing this code works great when testing in a browser (Chrome and Safari), but in the Android Emulator with PhoneGap, the alert message is never displayed which makes it look like the event binding is incorrect.

What am I missing?


Memo to self: RTFM.

Instead of binding to click with delegate, bind to vclick, i.e.

....
$('#lv_systems').delegate('li', 'vclick', function(){
....

Per the documentation,

Normalized event for handling touch or mouse click events

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜