I’m being a bit dense, how do I call an ajax method thats in another model?
I’m guessing its something to do with the “url: $(this).attr(‘href’),” but I’m not sure what to put in there?
In protected -> event -> view -> admin.php I have
Yii::app()->clientScript->registerScript('ajaxpaid', "
$('#event-client-grid a.ajaxpaid').live('click', function() {
$.fn.yiiGridView.update('event-client-grid', {
type: 'POST',
url: $(this).attr('href'),
success: function() {
$.fn.yiiGridView.update('event-client-grid');
}
});
return false;
});
");
The ajaxpaid method is in protected -> controllers -> eventclientcontroller.php
public function actionAjaxPaid($id,$client_id=null,$event_id=null)
{
// Do something with client_id and event_id
$model=$this->loadModel($id);
$model->paid = (!$model->paid);
$model->payment = $model->event->fee;
$model->update();
}