antennaio / jquery-bar-rating

jQuery Bar Rating Plugin - minimal, light-weight jQuery ratings.
http://antennaio.github.io/jquery-bar-rating/
MIT License
737 stars 260 forks source link

Problem in ajax request rating star not displaying #93

Open lenin2ud opened 7 years ago

lenin2ud commented 7 years ago

Hi this is my code , on first page loading it is working good , but when data load via ajax , star rating is working , can you help me to solve this issues
`

                            <!-- end media -->
                            <!--script start -->
                            <script type="text/javascript">
                            $(function() {
                                var cId = $("#postRating_"+'.$locationData['id'].').attr("cId");
                                var userId = '.$_SESSION['userId'].';

                                $("#postRating_"+'.$locationData['id'].').barrating({
                                        theme: "bootstrap-stars",
                                        showSelectedRating: false,
                                        initialRating: '.$ratingTotalDisplay.',

                                        onSelect: function(value, text) {
                                            if(value && userId){
                                                $("#jp_popup").modal("show", {backdrop: "static", keyboard: false});
                                                $("#jp_popup_title").html("<p class="text-center">Please Wait Loading</p>");
                                                $("#jp_popup_content").html("<p class="text-center"><img src="'.__SITEURL__.'ajax-loader.gif" alt="Please Wait Loading" align="center" ></p>");  
                                                $.post("ajax_call.php",
                                                {
                                                mode:"rating",
                                                refeId: cId,
                                                userId: userId,
                                                value:value
                                                },
                                                function(data, status){
                                                    var results =JSON.parse(data);
                                                    console.log(results);
                                                    if(results.status){
                                                        $("#jp_popup").modal("hide");
                                                        $("#jp_popup_title").html("");
                                                        $("#jp_popup_content").html("");  
                                                    } else {
                                                        $("#jp_popup").modal("show");
                                                        $("#jp_popup_title").html(results.msg);
                                                        $("#jp_popup_content").html(results.msg);                        
                                                    }
                                                //$(".pleaseWait").hide();
                                                });        
                                            } else {
                                                $("#jp_popup").modal("show");
                                                $("#jp_popup_title").html("Rating");
                                                $("#jp_popup_content").html("<h4>Please login to Rating</h4> <br/><div class="text-center clearfix"><a href="'.__SITEURL__.'login"  class="btn btn-custom">Click Here To Login</a></div>");   
                                            }
                                        },
                                        onClear: function(value, text) {
                                        }
                                    });  

                                });                                        
                            </script> 
                            <!--script end -->   
                            <div class="coupon-meta">`