简化:jqtouch 移动应用程序 ajax 加载问题

发布于 2024-09-15 07:26:45 字数 352 浏览 2 评论 0原文

在 jqtouch 和 iui 中,如果您想点击 This is a FEED 之类的链接并动态加载内容,该怎么办

的?

我尝试将单击处理程序绑定/实时到“a”和父“div”上,但它永远不会被触发,只是实际跟踪链接的事件。谢谢。

这是我的其他问题的简化版本:

jqtouch移动应用程序ajax加载问题

In jqtouch and iui, what do you do if you want to follow a link like <a href="#feed-49">This is a FEED</a> AND dynamically load the content of the <div id="feed-49"></div>?

I've tried bind/live a click handler onto the "a" and onto a parent "div" but it never gets fired, just the event for actually following the link. Thanks.

This is a simplified version of my other question:

jqtouch mobile app ajax loading issue

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

醉生梦死 2024-09-22 07:26:45

这取决于您希望页面预加载还是按需加载。

如果您希望它预先加载,您可能需要填写页面,例如 $(document).ready

$(document).ready(function(){
    $('#feed-49').load('feed-49.html');
});

如果您希望它按需加载,您可以收听 < code>pageAnimationStart 事件:

$('#feed-49').bind('pageAnimationStart', function(event, info){ 
    if (info.direction == 'in') 
        $(this).load('feed-49.html');
});

您可能需要阅读 jQTouch 有关回调事件的文档

It depends whether you want the page pre-loaded or load-on-demand.

If you want it pre-loaded, you might want to fill in the page upon, say, $(document).ready:

$(document).ready(function(){
    $('#feed-49').load('feed-49.html');
});

If you want it to load on-demand, you can listen to the pageAnimationStart event:

$('#feed-49').bind('pageAnimationStart', function(event, info){ 
    if (info.direction == 'in') 
        $(this).load('feed-49.html');
});

You may want to read the jQTouch's documentation on callback events.

违心° 2024-09-22 07:26:45

我刚刚经历了您所经历的事情,并且确切地知道如何解决它。您需要将该 XML 转换为 JSON 对象,该对象将编号为 [0]、[1] 等。

>这个 JQuery 插件非常好用http://www.fyneworks .com/jquery/xml-to-json/ 将该 JS 添加到您的应用程序中。然后,解析 XML 函数会将所需的 XML 节点(如通道内的项目节点)转换为 JSON 对象,然后对项目进行编号。

那么看看我如何清空当前的项目列表,构建项目列表,并向具有“sun”类的列表项目添加自定义 CLICK 函数(我喜欢 jquery)。然后该函数会将其父节点标题和 desc 添加到需要它的 div 中。 href 会将其推送到新的 jqtouch DIV,该 DIV 将处理所有详细信息。酷吧?如果这有效的话请投票给我。它对我来说确实如此,就像一种魅力。

function parseXml(xml)
{ 
  $('#feedList').html('');
  var rss = $.xml2json(xml); 
  $.each(rss.channel.item, function(i, item)
    { 
    $('#feedList').empty().append('<li class=sun'+i'><a href=#contentDiv>'+item.title+'</a></li>'); 
    $('.sun'+i).click(function() {
      $('#titleDiv').empty().append(item.title);                
      $('#descDiv').empty().append(item.description);   
      }); 
   }); 
};

I just went through what you are going through and know exactly how to solve it. You need to turn that XML into JSON objects, which will be numbered [0],[1], etc.

This JQuery plugin works and rocks : http://www.fyneworks.com/jquery/xml-to-json/ Add that JS to your app. Your parse XML function will then convert the XML nodes you want (like item nodes within a channel) into JSON objects and then numbers the items.

So look how I then empty the current list of items, build a list of the items and add a custom CLICK function to the list items with a class of "sun" (i love jquery). That function then will add it's parent node title and desc to the divs that need it. The href will push it to the new jqtouch DIV which will handle all the detail info. Cool 'eh? Vote me up if this works. It did for me, like a charm.

function parseXml(xml)
{ 
  $('#feedList').html('');
  var rss = $.xml2json(xml); 
  $.each(rss.channel.item, function(i, item)
    { 
    $('#feedList').empty().append('<li class=sun'+i'><a href=#contentDiv>'+item.title+'</a></li>'); 
    $('.sun'+i).click(function() {
      $('#titleDiv').empty().append(item.title);                
      $('#descDiv').empty().append(item.description);   
      }); 
   }); 
};
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文