我尝试添加 htmloptions“确认”,但它不起作用,尝试添加对话框,但无法处理因此而出现的所有错误,尝试谷歌搜索,但没有结果。 任何人都可以建议一种快速方法,在实际更新数据库之前询问用户是否确定要对页面进行 3 星评级?
编辑:这是我在 CStarRatingWidget 中使用的
'callback' =>'
// updates the div with the new rating info, displays a message for 5 seconds and makes the //widget readonly
function (){
jQuery.getJSON(
"'. $this->createUrl ( 'place/rating', array('ratingId'=>$model->rating_id ,'ajax'=>'rating')) . '",
{ val: $(this).val()},
function (data) {
if (data.status == "success") {
$("#rating_success_' . $model->rating_id . '").html(data.div);
$("#rating_success_' . $model->rating_id . '").fadeIn("slow");
var pause = setTimeout("$(\"#rating_success_' . $model->rating_id . '\").fadeOut(\"slow\")", 5000);
$("#rating_info_' . $model->rating_id . '").html(data.info);
$("input[id*=' . $model->rating_id . '_]").rating("readOnly", true);
}
}
);
}'
最佳答案
您可以简单地使用 confirm function :
'callback' =>'
function (){
if (confirm("Asking comething?")) {
jQuery.getJSON(
"'. $this->createUrl ( 'place/rating', array('ratingId'=>$model->rating_id ,'ajax'=>'rating')) . '",
{ val: $(this).val()},
function (data) {
if (data.status == "success") {
$("#rating_success_' . $model->rating_id . '").html(data.div);
$("#rating_success_' . $model->rating_id . '").fadeIn("slow");
var pause = setTimeout("$(\"#rating_success_' . $model->rating_id . '\").fadeOut(\"slow\")", 5000);
$("#rating_info_' . $model->rating_id . '").html(data.info);
$("input[id*=' . $model->rating_id . '_]").rating("readOnly", true);
}
}
);
}
}'
关于javascript - Yii 如何要求用户在 CStarRating 中确认他的选择,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23547570/