javascript inside the rendered page is NOT rendered in YII render partial

I am trying to render a page as below from my controller


$this->renderPartial("_ReservationDetails",array('rowarray'=>$rowarray,'CalendarID'=>$CalendarID),false,true);

in my view file, _ReservationDetails I have the following content


....

...

<td>

<button id="btnPrint" onclick="return PrintReciept();" class="btn btn-small" type="button">Print Reservation</button>

 </td>

....



I wrote a script inside the _ReservationDetails as below




<script>

public function PrintReciept()

{

alert("I am here!");

return false;

}

</script>



BUT!! When I click on "PrintReservation Button" It throws an error in the console… PrintReciept() is not found!! how???

you can do it in the jquery way:


$(document).ready(function(){

    $('#btnPrint').click(function(){


     });


});

That worked for me but I can’t get this working, how do I register another javascript function within?




 $(document).ready(function(){




                                    $('#btnPrint').click(function(){

                                     

                                      


                                      callthisone();

                                      


                                   

                                        return false;


                                     });


                                    public function callthisone()

                                      {

                                          alert("I am called");


                                      }


                                });



the "public" keyword is wrong in javascript

this would work




<script type="text/javascript">

$(document).ready(function() {


	$('#btnPrint').click(function() {

		callThisOne();

		return false;

	});


	function callThisOne() {

		alert("I am called");

	}


});

</script>