Sachy
(Sachin Mandalia)
December 24, 2014, 11:40am
1
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???
oligalma
(Marc Oliveras)
December 24, 2014, 11:44am
2
you can do it in the jquery way:
$(document).ready(function(){
$('#btnPrint').click(function(){
});
});
Sachy
(Sachin Mandalia)
December 24, 2014, 12:02pm
3
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");
}
});
oligalma
(Marc Oliveras)
December 24, 2014, 1:00pm
4
the "public" keyword is wrong in javascript
alirz23
(Ali Raza)
December 25, 2014, 4:54am
5
this would work
<script type="text/javascript">
$(document).ready(function() {
$('#btnPrint').click(function() {
callThisOne();
return false;
});
function callThisOne() {
alert("I am called");
}
});
</script>