在jquery mobile中创建动态列表视图时,.listview()不是函数错误 [英] .listview() is not a function error when creating a dynamic listview in jquery mobile

查看:123
本文介绍了在jquery mobile中创建动态列表视图时,.listview()不是函数错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在查询facebook api后在jquery mobile中创建动态列表视图,以检索用户的新闻源。以下是我加注的部分内容:

I am trying to create a dynamic listview in jquery mobile, after querying the facebook api, to retrieve a user's news feed. Here's part of my mark up:

markup += '<li><a href=""><img src="https://graph.facebook.com/' + id + '/picture">'+'<h4>' + name + '</h4><p>' + short_post +'....</p></a></li>';

然后我有,

 $(newsfeedposts).append(markup);

$(newsfeedposts).trigger("create");

然后我打电话给

$(newsfeedposts).listview("refresh");

我收到类型错误:TypeError:$(...)。listview不是函数

I get a type error: TypeError: $(...).listview is not a function

我的html div标签是这个

my html div tag is this

  <div data-role="content"> <div class ="post">
    <ul data-role="listview"  class="ui-listview" id="newsfeedposts" data-divider-theme="b" data-theme="a" data-overlay-theme="a" data-autodividers="true" data-inset="true">
</ul>
  </div>

如果你发现我做错了,请告诉我。这已经花了这么长时间......

please let me know if you identify what Im doing wrong.This has been taking so longg...

推荐答案

你没有正确使用jQuery-selector。要使用id定位元素,请使用 $('#element_id')以及类 $('。element_class')<的元素/ code>。因此,您的选择应如下所示。

You're not using jQuery-selector the right way. To target an element with an id, use $('#element_id') and for an element with a class $('.element_class'). So, your selection should be as below.

$('#newsfeedposts').append(markup);

然后

$('#newsfeedposts').listview('refresh');

这篇关于在jquery mobile中创建动态列表视图时,.listview()不是函数错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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