1

我正在尝试获取显示在页面内容部分的数据。在主页中,我正在加载一个 xml 文件ajax(),它在列表视图中显示数据。当我们单击列表中的项目时,它会在动态创建的单独页面中打开该相关文件。因此,每个项目都包含单独的文件(位于 .txt 文件中)。在该动态页面([data-role="content"])中,我正在加载一个文件其中包含该项目相关数据。我想获取文件数据。

创建用于在文件中显示数据的动态页面:

$($.mobile.pageContainer).append('<div data-role="page" id="' + seq + '" class="items">
  <div data-role="content" id="desc"></div>
  <div data-role="footer" data-position="fixed" class="my-footer">
  <div class="ui-block-a ui-bar-a" data-theme="a">
  <div align="left" style="padding-left:5px;padding-top:3px;height:33px;height:40px;">
  <a href="#home" class="ui-btn-left" data-role="button" data-icon="home" data-iconpos="notext"></a>
  </div></div>
  <div class="ui-block-b ui-bar-a"><div align="center" style="padding-top:3px;height:33px;text-align:center;height:40px;">
  <div style="padding-bottom:7px;"><a href="" data-role="button" class="addToFavoritesDiv">Bookmark</a>
  <a href="" data-role="button" class="shareDiv">Share</a></div></div></div><div class="ui-block-c ui-bar-a">
  <div align="right" style="padding-top:3px;height:33px;height:40px;">
  <a href="#" class="ui-btn-right" data-role="button" data-icon="back" data-rel="back" data-iconpos="notext"></a></div></div></div></div>');

$('[data-role=page]#' + seq + ' [data-role=content]').load(file);

实际上我localStorage用来存储数据。数据以列表视图的形式存储一切都很好,但我尝试获取页面的 url。当我单击存储的数据项时,它会打开该文件。但问题是我实现swipenextprevious页面的效果(列表视图中的项目)。

var url = $(location).attr('href');
var demo = localStorage.getItem(url);
// var s = '<li data-role=\"list-divider\"></li>';
$("#favoritesList").append('<li id="add"><a href="' + url + '" style="text-decoration:none;color:black">' + demo  + '</a></li>').attr('url', url);

所以我想当我得到那个url时,localStorage如果我们上下滑动它也会加载其他文件。有什么想法可以获取文件中唯一选定的数据。

提前致谢。

4

0 回答 0