【发布时间】:2015-08-19 02:44:36
【问题描述】:
我有一个 Rails 应用程序,我在其中使用 jquery Raty 插件我已将 Raty 包含在 gemfile 中
gem 'jquery-raty-rails', github: 'bmc/jquery-raty-rails'
在 application.js 中我已经包含
//= require jquery.raty
//= require jquery.raty.min
我已将其包含在 javascript 中
$('#star-log').raty({
target : '#hint-log',
targetType : 'score',
targetKeep : true
});
$('#star-comm').raty({
target : '#hint-comm',
targetType : 'score',
targetKeep : true
});
$('#star-tech').raty({
target : '#hint-tech',
targetType : 'score',
targetKeep : true
});
$('#star-overall').raty({
target : '#hint-overall',
targetType : 'score',
targetKeep : true,
readOnly : true
});
星级评分的视图为
<div class="row">
<div class=" col s12 m6 logical">
<label>Logical & Analytical Skills</label>
<div id="star-log" > </div>
<%= f.text_field :log_skill, :id=>'hint-log' %>
</div>
<div class=" col s12 m6">
<label>Communication skills</label>
<div id="star-comm" ></div>
<%= f.text_field :comm_skill, :id=>'hint-comm' %>
</div>
</div>
<div class="row">
<div class=" col s12 m6">
<label>Technical Skills</label>
<div id="star-tech" id="star-tech"></div>
<%= f.text_field :log_skill, :id=>'hint-tech' %>
</div>
<div class="col s12 m6">
<label >Overall Rating</label>
<div id="star-overall" id="star-read"></div>
<%= f.text_field :log_skill, :id=>'hint-overall' %>
</div>
</div>
我有 4 个星级评定字段
- 逻辑和分析能力
- 沟通技巧
- 技术技能
- 综合能力
所以现在用户将在前三星级评分中进行评分,并且通过这些评分,整体技能(只读)将在评分时更新,或者我们可以说整体技能评分将是前三个技能的平均值,它将自动更新并不断显示星星 我该怎么做?
【问题讨论】:
标签: javascript jquery ruby-on-rails ruby-on-rails-4.1 raty