简体   繁体   English

页面更改期间的jQuery Mobile调用功能

[英]jQuery Mobile call function during page change

I'm using jQuery Mobile and want to call a function after clicking on an anchor. 我正在使用jQuery Mobile,想在单击锚点后调用一个函数。 This function will put data in the listview visible on the called page. 此函数会将数据放在被调用页面上可见的列表视图中。 Unfortunately it does not work. 不幸的是,它不起作用。 Here is some code, I really hope you can help me! 这是一些代码,我真的希望你能帮助我!

<a href="#pageXY" onclick="changeActorInfo(5)" data-transition="flip">
   <img class="tmdbCast1" width="100" height="150">
   <span id="springboardLabelActors" class="tmdbCast1name"></span>
</a>

Firebug returns the followin: Error: cannot call methods on listview prior to initialization; Firebug返回以下信息:错误:初始化前无法在listview上调用方法; attempted to call method 'refresh' 尝试调用方法“刷新”

Thank you for your help! 谢谢您的帮助! If you need more just tell me! 如果您需要更多,请告诉我!

Edit: 编辑:

function changeActorInfo(cID) {

actorID = cID;
getActorInfo(actorID);

}; };

function getActorInfo(pID){
$('.dListDarsteller').show().listview('refresh');
$('.logoListDarsteller').hide();
$.ajax({
    url: "http://api.themoviedb.org/3/person/" +pID+ "?api_key=XXX&append_to_response=credits",
    dataType: 'jsonp',
    success: function(results){
        var name = results.name;
        $('.tmdbTitelDarsteller').html('<br><span class="titel">' +name);
        (...)
    }
});

} }

Your function is calling .listview('refresh'); 您的函数正在调用.listview('refresh'); before the content has been initialized by jQuery Mobile. 在jQuery Mobile初始化内容之前。 In any case you only be calling .listview('refresh'); 无论如何,您只能调用.listview('refresh'); after dynamic content has been added to your listview object. 将动态内容添加到listview对象之后。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM