How to call an action with ajax from a check click??
How to call an action with ajax from a check click??
ok im trying to do it this:
<?php
echo CHtml::button('All', array('id'=>'selectAll'))
. CHtml::button('None', array('id'=>'selectNone')); ?>
<br><br>
<?php
echo cHtml::checkBoxList($model->RoleName,'RoleName',CHtml::listData(Yii::app()->authManager->getRoles(), 'name', 'name'),
array(
'class'=>'UserRole_RoleName',
));
?>
<script type="text/javascript">
/*<![CDATA[*/
$('#selectAll').click(function(){
$('.UserRole_RoleName').attr('checked','checked');
});
$('#selectNone').click(function(){
$('.UserRole_RoleName').removeAttr('checked');
});
jQuery(function($) {
jQuery('.UserRole_RoleName').click(function(){
checked=jQuery('.UserRole_RoleName').is(':checked');
jQuery.ajax({
type: 'POST',
url: '',
'cache':false,
'data':'role=Admin&verificado='+checked,
'success':function(){
alert('sucesso');
}
});
});
});
/*]]>*/
</script>
how to send the selected name role of the checkbox?