I have a CHtml ajaxSubmitButton that works fine:
<div class="row buttons">
<?php
echo CHtml::ajaxSubmitButton(
Yii::t('applicant','Save'),
CHtml::normalizeUrl(array('applicant/addPassport','render'=>false)),
array(
'success'=>'js: function(data) {
$("#applicantPassportDialog").dialog("close");
}',
'failure'=>'js: function(data) {
alert("error");
}',
),
array('id'=>'closeApplicantPassportDialog')
);
?>
</div>
But when I try to use the TbHtml ajaxButton, the ‘success’ function is not being called. Are the ajaxOptions wrong in the following code?
echo TbHtml::ajaxButton(
$model->isNewRecord ? 'Create' : 'Save',
array('applicant/addPassport'),
array(
'dataType'=>'json',
'type'=>'post',
'success'=>'js: function(data) {
$("#applicantPassportDialog").dialog("close");
}',
'failure'=>'js: function(data) {
alert("error");
}',
),
array(
'id'=>'closeApplicantPassportDialog',
'color'=>TbHtml::BUTTON_COLOR_PRIMARY,
'size'=>TbHtml::BUTTON_SIZE_SMALL,
)
);