gpt4 book ai didi

jquery - 在 jquerymobile 中动态创建的评级星插件中未正确应用样式

转载 作者:行者123 更新时间:2023-11-28 18:51:33 25 4
gpt4 key购买 nike

我正在使用 jquery rating star 插件,静态使用时一切正常,但是当我动态创建 ListView 并将“选项”输入控件放入其中时,它从不应用样式。

在我已加载样式表中:

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="viewport" id="viewport" content="width=device-width,height=device-height,initial-scale=1.0,user-scalable=no"/>
<link rel="stylesheet" href="js/rating/jquery.rating.css" />
<link rel="stylesheet" href="css/themes/etensr.theme.css" />
<script src="jquery.1.7.1.min.js" type="text/javascript"></script>
<script type="text/javascript" src="js/rating/jquery.rating.js"></script>
<script type="text/javascript" src="jquery.mobile.1.0.min.js"></script>
</head>

和页面:

<div data-role="page" id="subcategories" data-theme="a">
<div class="header" data-role="header" style="height: 42px;" >
<a data-rel="back" data-role="button" data-theme="c">Back</a>
<a href="order.html" data-role="button" data-theme="c" data-icon="gear" data-iconpos="right" class="ui-btn-right">0.00 SRD - </a>
</div>
<div data-role="content" id="subcategoryCnt">
<ul id="subcategoryList" data-role="listview" data-theme="a" data-dividertheme="c" >
<li data-icon="arrow-r" >
<img src="images/thumb80x80.jpg" />
<div>
<div style="float:left;"><p>Product</p></div>
<div style="float:right;font-size: 12px;">Price</div>
<div style="clear:both;"></div>
<div style="float:left;">
<input name="star1" type="radio" data-role="none" class="star" disabled="disabled" />
<input name="star1" type="radio" data-role="none" class="star" disabled="disabled" />
<input name="star1" type="radio" data-role="none" class="star" disabled="disabled" checked="checked"/>
</div>
</div>
</li>
</ul>
</div>
</div>

所有这些都正确显示,但是当我动态加载 ListView 元素时,输入 radio 不会像星星一样呈现,而是呈现正常的单选按钮:

 <div data-role="page" id="subcategories" data-theme="a">
<div class="header" data-role="header" style="height: 42px;" >
<a data-rel="back" data-role="button" data-theme="c">Back</a>
<a href="order.html" data-role="button" data-theme="c" data-icon="gear" data-iconpos="right" class="ui-btn-right">0.00 SRD - </a>
</div>
<div data-role="content" id="subcategoryCnt">
<script type="text/javascript">
GetSubcategories();
</script>
</div>
</div>

JS 是:

function GetSubcategories() {
subcategories = result.GetSubcategoriesResult;
if (subcategories.length > 0) {
var html = '<ul id="subcategoryList" data-role="listview" data-theme="a" data-dividertheme="c" >';
for (i = 0; i < subcategories.length; i++) {
html = html + '<li data-role="list-divider">' + subcategories[i].Name + '</li>';
prods = subcategories[i].Products;
if (prods.length > 0) {
for (j = 0; j < prods.length; j++) {
html = html +
'<li data-icon="arrow-r" >' +
'<a href="products.html" rel="external">' +
'<img src="images/thumb80x80.jpg" />' +
'<div>' +
'<div style="float:left;"><p>' + prods[j].Name + '</p></div>' +
'<div style="float:right;font-size: 12px;">' + prods[j].Price + ' SRD</div>' +
'<div style="clear:both;"></div>' +
'<div style="float:left;">' +
'<input name="star' + prods[j].Id + '" type="radio" data-role="none" class="star" disabled="disabled" />' +
'<input name="star' + prods[j].Id + '" type="radio" data-role="none" class="star" disabled="disabled" />' +
'<input name="star' + prods[j].Id + '" type="radio" data-role="none" class="star" disabled="disabled" checked="checked"/>' +
'</div>' +
'</div>' +
'</a>' +
'</li>';
}
}
}
html += '</ul>';
}
$('#subcategoryCnt').html(html);
$('#subcategoryList').listview();
}

当我执行相同但动态的操作时,除了输入 radio 没有像星星那样显示之外,所有内容都正确显示。

我做错了什么?谢谢

最佳答案

关于data-icon="star"

另外我认为你仍然需要刷新 jQM

JS

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

关于jquery - 在 jquerymobile 中动态创建的评级星插件中未正确应用样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9154887/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com