【问题标题】:Inline Editing with best in place具有最佳位置的内联编辑
【发布时间】:2014-09-22 21:19:09
【问题描述】:

我有一个用户索引页面,在该页面中我显示了一条微博。

一个用户有多个微博。

UserId, UserName, MicropostName
  1       Lipsum     Loren

我想使用 Inline 更新 Loren,但它不起作用。

我正在使用http://railscasts.com/episodes/302-in-place-editing

我在 Gemfile 中添加了 best_in_place Gem 并遵循要求流程但无法正常工作

请帮帮我。

提前致谢

【问题讨论】:

  • 请粘贴一些代码并更具体地询问,我相信在那之后我可以提供帮助:)
  • 您还有问题吗?下面的答案有帮助吗?

标签: ruby-on-rails ruby-on-rails-3 best-in-place


【解决方案1】:

首先将 best_in_place 添加到 gem 文件中。

gem 'best_in_place'

接下来将这个 JQuery 代码添加到 Javascript 中

$(document).ready(function(){
   $(".best_in_place").best_in_place();
});

鉴于这样使用 best_in_place,这里的 partner_info 是字段名

<%= best_in_place partner_info, :type => :text %>

最后你应该有一个更新方法,该方法将在字段时由 best_in_place 调用。

def update

  @partner_info = PartnerInfo.find(params[:id])



respond_to do |format|

    if @partner_info.update_attributes(params[:partner_info])

      format.html { redirect_to @partner_info, notice: 'PartInfo was successfully updated.' }

      format.json { head :no_content }

    else

      format.html { render action: "edit" }

      format.json { render json: @partner_info.errors, status: :unprocessable_entity }

    end

end

end

用你的代码检查一下。我希望这会对你有所帮助。

【讨论】:

    猜你喜欢
    • 2019-09-15
    • 2016-06-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-30
    • 2015-08-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多