项目作者: alfa6661

项目描述 :
Yii2-raty is a Star Rating Plugin wrapper for jQuery Raty plugin
高级语言: JavaScript
项目地址: git://github.com/alfa6661/yii2-raty.git
创建时间: 2015-06-09T08:44:16Z
项目社区:https://github.com/alfa6661/yii2-raty

开源协议:

下载


yii2-raty

StyleCI
Total Downloads
Latest Stable Version
Latest Unstable Version
License

Yii2-raty is a wrapper for jQuery Raty plugin. jQuery Raty is a plugin that generates a customizable star rating automatically.

Installation

The preferred way to install this extension is through composer.

Either run

  1. php composer.phar require --prefer-dist alfa6661/yii2-raty "*"

or add

  1. "alfa6661/yii2-raty": "*"

to the require section of your composer.json file.

Usage

Once the extension is installed, simply use it in your code by :

  1. // Usage
  2. <?= \alfa6661\widgets\Raty::widget([
  3. 'name' => 'user-vote',
  4. 'options' => [
  5. // the HTML attributes for the widget container
  6. ],
  7. 'pluginOptions' => [
  8. // the options for the underlying jQuery Raty plugin
  9. // see : https://github.com/wbotelhos/raty#options
  10. ]
  11. ]); ?>
  12. // Usage with model
  13. <?= \alfa6661\widgets\Raty::widget([
  14. 'model' => $model,
  15. 'attribute' => 'rating',
  16. 'options' => [
  17. // the HTML attributes for the widget container
  18. ],
  19. 'pluginOptions' => [
  20. // the options for the underlying jQuery Raty plugin
  21. // see : https://github.com/wbotelhos/raty#options
  22. ]
  23. ]); ?>
  24. // Usage with ActiveForm and model
  25. <?= $form->field($model, 'point')->widget(\alfa6661\widgets\Raty::className(), [
  26. 'options' => [
  27. // the HTML attributes for the widget container
  28. ],
  29. 'pluginOptions' => [
  30. // the options for the underlying jQuery Raty plugin
  31. // see : https://github.com/wbotelhos/raty#options
  32. ]
  33. ]); ?>
  34. // Javascript events handling
  35. // Available event callbacks: Read Only, Click, Mouseover and Mouseout
  36. <?= \alfa6661\widgets\Raty::widget([
  37. 'name' => 'user-vote',
  38. 'options' => [
  39. 'class' => 'pull-left',
  40. 'id' => 'user-vote'
  41. ],
  42. 'pluginOptions' => [
  43. 'click' => new \yii\web\JsExpression('function(score, e) {
  44. alert(score);
  45. }')
  46. ]
  47. ]); ?>