Frage

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);
                        }
                    }
                );
            }'
War es hilfreich?

Lösung

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);
                    }
                }
            );
          }
        }'
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top