【发布时间】:2014-09-27 12:16:27
【问题描述】:
我正在使用 Yii 框架并尝试在我的 gridview 上启用 CStarRating。在输出 HTML 源代码中,我有以下内容:
<tr class="odd">
<td>Bob</td><td>
<span class="rating" id="6">
<input id="6_0" value="1" type="radio" name="6" />
<input id="6_1" value="2" type="radio" name="6" />
<input id="6_2" value="3" type="radio" name="6" />
<input id="6_3" value="4" type="radio" name="6" />
<input id="6_4" value="5" type="radio" name="6" />
</span>
</td>
</tr>
<tr class="even">
<td>Peter</td>
<span class="rating" id="9">
<input id="9_0" value="1" type="radio" name="9" />
<input id="9_1" value="2" type="radio" name="9" />
<input id="9_2" value="3" type="radio" name="9" />
<input id="9_3" value="4" type="radio" name="9" />
<input id="9_4" value="5" type="radio" name="9" />
</span>
</td>
</tr>
在 HTML 正文中,我有以下内容:
<script type="text/javascript">
jQuery(function($) {
jQuery('#6 > input').rating({'callback':function(){
url = "clients/update";
jQuery.getJSON(url, {id_client: '6', val: $(this).val()},
function() {
if (data.status !== "success"){
alert("error");
}});}});
jQuery('#9 > input').rating({'callback':function(){
url = "clients/update";
jQuery.getJSON(url, {id_client: '9', val: $(this).val()},
function() {
if (data.status !== "success"){
alert("error");
}});}});
});
</script>
但是当我点击星星时,什么也没发生。我是 JQuery 和 JSON 的新手,所以任何帮助都将不胜感激。谢谢!
【问题讨论】:
-
首先:请不要使用数字作为Id。
-
谢谢,我已经在前面连接了一个字符串,但仍然没有任何反应。我想我可能需要一些用于boydy onLoad 的脚本,但我不确定:(
-
在 click 函数中设置警报,看看是否触发了 click 事件。
-
对不起,点击功能在哪里?
-
对不起。我的意思是你的评级回调。他们被处决了吗?