jQuery Mobile的点击()上的ListView [英] jquery mobile click() on listview

查看:1250
本文介绍了jQuery Mobile的点击()上的ListView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有在jQuery Mobile的ListView中的一个问题。我想使用JSON从服务器加载一些数据,并填写你的列表视图的项目。这工作正常。但是,当我试图在一个新的加载项上点击反应,我不净得到事件!我想,我必须以某种方式刷新视图,有点不知道怎么办。

我做的 http://jsfiddle.net/VqULm/227/ <有点草图/ p>

当u击中点击按钮,我一个项目单击事件不再被跟踪。我如何获得Wokrs警报在新项目?

感谢ü非常的阅读!


解决方案

尝试

  $('#列表视图)上(咔哒,礼,函数(){
        警报(作品); //通过直接访问一个DOMElement物业编号点击华里
    });

jQuery和GT; 1.7

演示

  $('#列表视图礼')。生活('点击',功能(){
    警报(作品); //通过直接访问一个DOMElement物业编号点击华里
});

你的jQuery 1.6.4版本。

演示

为什么你需要这个

由于。您要添加列表视图页面重载后,所以无论如何对于那些取值应生活(对于使用jQuery的版本)或委托(jQuery的> 1.7)。

I have a problem with the listview in jquery mobile. I want to load some data from a server using JSON and fill thy listview with the items. That works fine. But when I am trying to react on a click on a new loaded item I do net get the event! I think I have to refresh the view somehow, bit do not know how.

I made a little sketch on http://jsfiddle.net/VqULm/227/

when u hit the click me button the click event on a item isn't tracked anymore. How do i get the "Wokrs" alert on the new items?

Thank u very much for reading!

解决方案

Try

    $('#listview').on('click', 'li', function() {
        alert("Works"); // id of clicked li by directly accessing DOMElement property
    });

with jQuery > 1.7

DEMO

OR

$('#listview li').live('click', function() {
    alert("Works"); // id of clicked li by directly accessing DOMElement property
});

with your jQuery version 1.6.4.

DEMO

why you need this

Because. you're adding li within listview after page reload, so any event for those lis should live (for jQuery version you used) or delegate (jQuery > 1.7).

这篇关于jQuery Mobile的点击()上的ListView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆