开发者

How to pass a variable into a dialog function?

How do i pass my rating variable from updateRating() function into my window.location.replace(url + rating) which in the "proceed" function in my dialog?

Here are my codes:

         <script type="text/javascript">

        $(document).ready(function(){
            $(".hireraccept").click(function(){
                     $('.jRating').jRating();
                     $("#dialog-rate").dialog("open");
                     itervalue = $(this).attr("value");


                    return false

        });


        $("#dialog-rate").dialog({

            autoOpen: false,
            resizable: false,
            height: 200,
            width: 200,        
            modal: true,
            buttons: {
                "Proceed": function(){

                    window.location.replace("{{ domain_url }}/workroom/accept/" + itervalue +"/" + rating);
                    $(this).dialog("close");

                }

            }


        });开发者_StackOverflow社区 }); </script>






  <script> 
  function updateRating(rate,proceed){
  goodtogo = proceed;

  rating = rate;

}  
</script>    


The problem here is that your variables goodtogo and rating are variables that are local to the function updateRating(). All you have to do is declare them within the global scope.

var goodtogo, rating;
function updateRating(value) {
    goodtogo = true;
    rating = value;
}


One option would be to create a global variable. Assign the value to it where it is appropriate. Then access it from within the "dialog"

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜