我使用的是best_in_place gem,因此我可以在我的索引视图中编辑多个学生。Best_in_place标签槽
虽然问题是,可用性很差。 我必须点击,输入信息,输入/点击并再次点击以编辑其他信息。
这是一种我可以按Tab键走槽的方法吗?
这里是指数代码:
<% @students.each do |student| %>
<tr>
<td><%= link_to .name, edit_student_path(student) %></td>
<td><%= best_in_place student, :oral %></td>
<td><%= best_in_place student, :writing %></td>
<td><%= best_in_place student, :participation %></td>
<td><%= best_in_place student, :grammar %></td>
<td><%= best_in_place student, :presence, type: :select, collection: [["Present", "Present"], ["Absent", "Absent"], ["", "-"]] %></td>
</tr>
<% end %>
我发现这一点:https://github.com/bernat/best_in_place/tree/master/lib/best_in_place
确定。 这是我现在得到的,但仍然不工作:/ 任何想法?
指数:
<td><%= best_in_place allan, :oral, :html_attrs => {:tabindex => 10} %></td>
<td><%= best_in_place allan, :writing, :html_attrs => {:tabindex => 11} %></td>
Users.js.coffee
jQuery ->
$('.best_in_place').best_in_place()
$ ->
$('span.best_in_place').focus ->
el = $(this)
el.click()
el.find(el.data('type')).attr('tabindex', el.attr('tabindex'))
是否有特殊的地方放置js代码? 我把它放在users.js中。但现在我得到一个错误。 – Allan
'语法错误:第7行的保留字“功能” (在C:/ Users/SpeedUp/My Documents/Aptana Studio 3 Workspace/participatio/app/assets/javascripts/users.js.coffee)。** ** Line 7是你的JS conde。 :/ ** – Allan
JS代码不适用于CoffeeScript,我更新了CoffeeScript版本的答案。 –