【问题标题】:rest_in_place select within a .each for loop在 .each for 循环中选择 rest_in_place
【发布时间】:2013-06-02 22:12:18
【问题描述】:

我在 Rails 3 中使用 rest_in_place gem 在返回模型结果的表中执行就地编辑。

对于编辑文本输入,我没有遇到任何问题。对于我的<td> 字段之一,我希望该字段在单击以进行编辑时,具有从系统内具有用户的用户模型填充的选择下拉框。

我尝试在我的模型中使用以下代码,但似乎 rest_in_place 期望此元素位于表单中。

HTML:

<td style="font-size: 10px;"><span class="rest-in-place" data-select="AbaseUser" data-formtype="select" data-object="marketer_import" data-attribute="new_user" data-url="<%= "/marketer_imports/#{marketer_import.id}" %>">
  <%= marketer_import.new_username unless marketer_import.new_username.nil? %>
</span></td>

Javascript:

RestInPlaceEditor.prototype.bindForm = function() {
  this.activateForm = RestInPlaceEditor.forms[this.formType].activateForm;
  return this.getValue = RestInPlaceEditor.forms[this.formType].getValue;
};

我在 Chrome 控制台中收到以下错误

Uncaught TypeError: Cannot read property 'activateForm' of undefined

【问题讨论】:

    标签: ruby-on-rails ruby ruby-on-rails-3


    【解决方案1】:

    我可以看到here,rest_in_place 默认不支持“选择”表单类型(仅输入和文本区域)。考虑改用best_in_placeRyan Bates 提供了一个很好的教程here

    【讨论】:

      猜你喜欢
      • 2021-09-28
      • 2015-11-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-18
      • 1970-01-01
      • 2012-10-11
      • 1970-01-01
      相关资源
      最近更新 更多