$id, 'type'=>$type]);
if( ( !$model instanceof ReactionButtons ) ){
$counters=[0,0,0,0,0,0];
}else{
$counters =json_decode( $model->counter, true );
}
?>
foreach( $counters as $key=>$val ){
?>
=$val?>
$key++;
}
?>
$this->registerJs(
<< {
$('#rbk_'+key).text(item);
if( item > 0 ) $('#rbki_'+key).addClass('active');
});
}
}
});
}
JS
,
yii\web\View::POS_END,
'reaction'
);
$this->registerJs(
<< {
$.post( "$getrurl", { 'id': $id, 'type': '$type'}, function( data ) {
if( data.status == 'ok' ){
if( Array.isArray(data.ret) ){
data.ret.forEach((item, key) => {
$('#rbk_'+key).text(item);
if( item > 0 ) $('#rbki_'+key).addClass('active');
});
}
}
});
}, 5000 );
JS
,
yii\web\View::POS_END,
'reaction2'
);
}