我正在尝试复制我们代码中其他地方使用的评级插件,但它失败了。可能是我将 js 和 css 包含在错误的顺序中。除非我将课程更改为 STAR,否则星星也不会出现。因为它是我只是得到单选按钮。该事件永远不会触发。在开发工具中比较两个页面(新页面和有效页面)时,一切似乎都是一样的。
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<link href='/assets/css/jquery.rating.css' type="text/css" rel="stylesheet"/>
<script src='/assets/js/jquery.MetaData.js' type="text/javascript" language="javascript"></script>
<script src='/assets/js/jquery.rating.pack.js' type="text/javascript" language="javascript"></script>
</head>
<script>
$(function(){
$('.auto-submit-star').rating({
**Uncaught type error: Object[object Object] has no method 'rating'**
callback: function(value, link){
// 'this' is the hidden form element holding the current value
// 'value' is the value selected
// 'element' points to the link element that received the click.
alert("The value selected was '" + value + "'\n\nWith this callback function I can automatically submit the form with this code:\nthis.form.submit();");
// To submit the form automatically:
//this.form.submit();
// To submit the form via ajax:
//$(this.form).ajaxSubmit();
$.ajax({
url: '/services/Mentor.cfc',
data: {
method: 'insertRating',
rating: value
},
//success: function(data){
// if (data == true) {
// alert('true!');
// }
// else {
// alert('false!');
// }
//}
});
}
});
});
</script>
<cfif qRating.recordCount GT 0>
<input name="rating_#request.target_id#" type="radio" class="star required" value="#request.target_id#_1"<cfif qRating.rating EQ 1> checked="checked" disabled="disabled"</cfif> />
<input name="rating_#request.target_id#" type="radio" class="star" value="#request.target_id#_2"<cfif qRating.rating EQ 2> checked="checked" disabled="disabled"</cfif> />
<input name="rating_#request.target_id#" type="radio" class="star" value="#request.target_id#_3"<cfif qRating.rating EQ 3> checked="checked" disabled="disabled"</cfif> />
<input name="rating_#request.target_id#" type="radio" class="star" value="#request.target_id#_4"<cfif qRating.rating EQ 4> checked="checked" disabled="disabled"</cfif> />
<input name="rating_#request.target_id#" type="radio" class="star" value="#request.target_id#_5"<cfif qRating.rating EQ 5> checked="checked" disabled="disabled"</cfif> />
<cfelse>
<input name="rating_#request.target_id#" type="radio" class="auto-submit-star star required" value="#request.target_id#_1" />
<input name="rating_#request.target_id#" type="radio" class="auto-submit-star star" value="#request.target_id#_2" />
<input name="rating_#request.target_id#" type="radio" class="auto-submit-star star" value="#request.target_id#_3" />
<input name="rating_#request.target_id#" type="radio" class="auto-submit-star star" value="#request.target_id#_4" />
<input name="rating_#request.target_id#" type="radio" class="auto-submit-star star" value="#request.target_id#_5" />
</cfif>