jqmobile中显示列表缩略图列表的问题
您好,我在 jqmobile 中显示缩略图列表时遇到问题。
如果我尝试过>
<li>
<img src="images/album-bb.jpg" />
<h3><a href="index.html">Broken Bells</a></h3>
<p>Broken Bells</p>
</li>
一切正常吗,看起来像>
http://jquerymobile.com/demos/1.0a3/docs/lists /lists-thumbnails.html
但是,如果我尝试通过
$(document).ready(function () {
$.ajax({
type: "GET",
url: "data.xml",
dataType: "xml",
success: xmlParser
});
});
function xmlParser(xml) {
//Hide .gif loader image if data are succesully fetched
// $('#load').fadeOut();
$(xml).find("SHOPITEM").each(function () {
$("ul").append("<li><img width=\"80px\" src=\""+$(this).find('IMGURL').text()+"\"/><h3><a href=\""+$(this).find('URL').text()+"\">"+$(this).find('PRODUCT').text()+"</a></h3><p>"+$(this).find('PRICE_VAT').text()+"</p></li>");
});
}
我显示的项目动态生成它,但内容格式不正确。
请问哪里可能有问题?
感谢您的任何建议..
Hello I have a problem with displaying thumbnail list in jqmobile.
If I tried>
<li>
<img src="images/album-bb.jpg" />
<h3><a href="index.html">Broken Bells</a></h3>
<p>Broken Bells</p>
</li>
Is everything O.K and looks it like>
http://jquerymobile.com/demos/1.0a3/docs/lists/lists-thumbnails.html
But if I try generate it dynamically via
$(document).ready(function () {
$.ajax({
type: "GET",
url: "data.xml",
dataType: "xml",
success: xmlParser
});
});
function xmlParser(xml) {
//Hide .gif loader image if data are succesully fetched
// $('#load').fadeOut();
$(xml).find("SHOPITEM").each(function () {
$("ul").append("<li><img width=\"80px\" src=\""+$(this).find('IMGURL').text()+"\"/><h3><a href=\""+$(this).find('URL').text()+"\">"+$(this).find('PRODUCT').text()+"</a></h3><p>"+$(this).find('PRICE_VAT').text()+"</p></li>");
});
}
I got items displayed, but content is not formated correctly.
Where can be problem please?
Thanks for any advice..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您现在可能已经解决了这个问题,但如果没有,为了其他可能有同样问题的人,我将发布这个潜在的解决方案:
很可能您的 CSS 没有应用于 DOM 元素(HTML ) 由 AJAX 函数生成并插入到 DOM 中。如果不进行处理,我怀疑您可能必须应用内联的 CSS,插入的 HTML 才会生效。
我遇到了通过 AJAX 插入 HTML 并尝试对其应用新的 javascript 功能的类似问题。 jQuery 提出了一个名为“live()”函数的解决方案,但我不确定 jQuery 是否有一个内置函数可以以相同的方式应用 CSS。
所以像这样的一行:
将变成:
Rick
You probably have already solved this by now, but if not, and for the sake of others who may have the same problem, I'll post this potential solution:
It's very likely that your CSS is not being applied to the DOM Elements (HTML) being generated and inserted into the DOM by your AJAX function. Without working on it, I would suspect you may have to apply your CSS inline with the HTML being inserted to it will take affect.
I've run into a similar problem with HTML inserted via AJAX and trying to apply new javascript functionality to it. jQuery came up with a solution for that called the "live()" function, but I'm not sure jQuery has a built function to apply CSS in the same way.
So a line like this:
would become:
Rick
我认为您需要刷新 javascript 中的列表视图才能获取格式:
来自 http:// /jquerymobile.com/test/docs/lists/docs-lists.html:
$('#mylist').listview('刷新');
i think you need to refresh the listview in javascript to get the formatting:
From http://jquerymobile.com/test/docs/lists/docs-lists.html:
$('#mylist').listview('refresh');