alfa6661 / yii2-raty
Yii2 的 jQuery Raty 插件包装器
1.0
2015-08-18 08:05 UTC
Requires
- yiisoft/yii2: *
This package is auto-updated.
Last update: 2024-09-11 15:29:39 UTC
README
Yii2-raty 是一个 jQuery Raty 插件 的包装器。jQuery Raty 是一个可以自动生成可定制星级评级的插件。
安装
安装此扩展的首选方式是通过 composer。
运行以下命令:
php composer.phar require --prefer-dist alfa6661/yii2-raty "*"
或者将以下内容添加到您的 composer.json
文件的 require 部分中:
"alfa6661/yii2-raty": "*"
用法
扩展安装完成后,只需在您的代码中通过以下方式使用它:
// Usage <?= \alfa6661\widgets\Raty::widget([ 'name' => 'user-vote', 'options' => [ // the HTML attributes for the widget container ], 'pluginOptions' => [ // the options for the underlying jQuery Raty plugin // see : https://github.com/wbotelhos/raty#options ] ]); ?> // Usage with model <?= \alfa6661\widgets\Raty::widget([ 'model' => $model, 'attribute' => 'rating', 'options' => [ // the HTML attributes for the widget container ], 'pluginOptions' => [ // the options for the underlying jQuery Raty plugin // see : https://github.com/wbotelhos/raty#options ] ]); ?> // Usage with ActiveForm and model <?= $form->field($model, 'point')->widget(\alfa6661\widgets\Raty::className(), [ 'options' => [ // the HTML attributes for the widget container ], 'pluginOptions' => [ // the options for the underlying jQuery Raty plugin // see : https://github.com/wbotelhos/raty#options ] ]); ?> // Javascript events handling // Available event callbacks: Read Only, Click, Mouseover and Mouseout <?= \alfa6661\widgets\Raty::widget([ 'name' => 'user-vote', 'options' => [ 'class' => 'pull-left', 'id' => 'user-vote' ], 'pluginOptions' => [ 'click' => new \yii\web\JsExpression('function(score, e) { alert(score); }') ] ]); ?>