javascript - Yii 如何要求用户在 CStarRating 中确认他的选择

标签 javascript php yii callback

我尝试添加 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/

相关文章:

javascript - Highcharts 折线图 - 某些类别不可见

JavaScript:函数返回最接近的值

javascript - 在 mongoose 中执行 CRUD 操作时异步/等待

php - 在页面加载时设置选择值

php - 如果右连接不返回任何行,则 mysql 设置为 null 或 0

php - 使用 GridView 在 Yii2.0 中显示过滤器的空白行

javascript - 使用 jQuery :contains 时如何忽略后代元素中的匹配项

PHP - 防止 F12 提交黑客攻击

php - $_GET[] 和通配符的 MySQL 注入(inject)安全性的正确语法是什么

php - 如何在 OSX 10.8.4 下使用适用于 Yii 和 Netbeans 的 MAMP 2.1.4 安装 phpunit?