我做了下一个:
代码:
echo StarRating::widget([
'name' => $post->post_rate,
'value' => isset($post->post_rate) ? $post->post_rate : 0,
'pluginOptions' => [
'size'=>'xs',
'filledStar' => '★',
'emptyStar' => '☆',
'showCaption' => false,
],
'pluginEvents' => [
"rating.change" => "function() \n\t{\n\t alert('ok'); \n\t}\n\t"
],
问题: 为什么在我躲上一颗星之后不再保持警觉?
答案 0 :(得分:0)
当您尝试首次使用此插件时,如果您查看rating:change
documentation,则应该rating.change
而不是javascript
,这是常见错误将其更改为以下
echo StarRating::widget([
'name' => $post - > post_rate,
'value' => isset($post - > post_rate) ? $post - > post_rate : 0,
'pluginOptions' => [
'size' => 'xs',
'filledStar' => '★',
'emptyStar' => '☆',
'showCaption' => false,
],
'pluginEvents' => [
"rating:change" => "function() { alert('ok'); }"
],