gpt4 book ai didi

javascript - JQuery 星级评级插件和 Ajax 的问题

转载 作者:行者123 更新时间:2023-11-29 20:25:29 27 4
gpt4 key购买 nike

我是 JQuery、Ajax、JavaScript 的新手

我对 JQuery star-rating-plugin 有疑问。我在某些页面中使用了它并且效果很好。但是,当我在 Ajax 页面中使用时,它的行为并不相同。

当页面重新加载时,不再显示任何内容。像以前一样隐藏输入,但不显示 div。

页面加载时我有这段代码:

<td class="rowstyle0" width="30%" align="left">
<a onclick="javascript:abrirConsultaNova('/projectManager/projectManager/atividade.do?method=consultar&id=219', 'Consultar 219');" href="#219">
<span class="star-rating-control">
<div class="rating-cancel" style="display: none;">
<a title="Cancel Rating"/>
</div>
<div id="avaliacao1_219" class="star-rating rater-0 star {split:2} star-rating-applied star-rating-readonly star-rating-on" style="width: 8px;">
<a title="1" style="margin-left: 0px;">1</a>
</div>
<div id="avaliacao2_219" class="star-rating rater-0 star {split:2} star-rating-applied star-rating-readonly star-rating-on" style="width: 8px;">
</div>
<div id="avaliacao3_219" class="star-rating rater-0 star {split:2} star-rating-applied star-rating-readonly star-rating-on" style="width: 8px;">
</div>
<div id="avaliacao4_219" class="star-rating rater-0 star {split:2} star-rating-applied star-rating-readonly star-rating-on" style="width: 8px;">
</div>
</span>
<input id="avaliacao1_219" class="star {split:2} star-rating-applied star-rating-readonly" type="radio" disabled="disabled" value="1" name="avaliacao219" style="display: none;"/>
<input id="avaliacao2_219" class="star {split:2} star-rating-applied star-rating-readonly" type="radio" disabled="disabled" value="2" name="avaliacao219" style="display: none;"/>
<input id="avaliacao3_219" class="star {split:2} star-rating-applied star-rating-readonly" type="radio" disabled="disabled" value="3" name="avaliacao219" style="display: none;"/>
<input id="avaliacao4_219" class="star {split:2} star-rating-applied star-rating-readonly" type="radio" disabled="disabled" value="4" name="avaliacao219" style="display: none;"/>
</a>
</td>

这是动态重新加载页面时的代码:

<td class="rowstyle0" width="30%" align="left">
<a onclick="javascript:abrirConsultaNova('/projectManager/projectManager/atividade.do?method=consultar&id=219', 'Consultar 219');" href="#219">
<input id="avaliacao1_219" class="star {split:2} star-rating-applied" type="radio" disabled="disabled" value="1" name="avaliacao219" style="display: none;"/>
<input id="avaliacao2_219" class="star {split:2} star-rating-applied" type="radio" disabled="disabled" value="2" name="avaliacao219" style="display: none;"/>
<input id="avaliacao3_219" class="star {split:2} star-rating-applied" type="radio" disabled="disabled" value="3" name="avaliacao219" style="display: none;"/>
<input id="avaliacao4_219" class="star {split:2} star-rating-applied" type="radio" disabled="disabled" value="4" name="avaliacao219" style="display: none;"/>
</a>
</td>

如何让 div 出现在回复中?

最佳答案

我在 Ajax 场景中遇到了问题。只有单选按钮出现。我只是在加载内容后 Hook 了事件。

$('input[type="radio"].star').rating(); // Hook the events.

也许您可以通过以下语句启用星星。

$('input[type="radio"].star').rating('enable');

关于javascript - JQuery 星级评级插件和 Ajax 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1446619/

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