문제

I tried to add htmloptions "confirm" and it doesnt work, tried to add dialog box and couldnt handle all the errors that came because of that, tried to google and no results. Can anyone suggest a quick way for asking user if he is sure he wants to rate a page with 3 stars for example, before actually updating the database?

edit: this is what i use in 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);
                        }
                    }
                );
            }'
도움이 되었습니까?

해결책

You can simply use 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);
                    }
                }
            );
          }
        }'
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top