【问题标题】:rails 3 best_in_place edit not working without refreshing the pagerails 3 best_in_place 编辑在不刷新页面的情况下不起作用
【发布时间】:2012-04-12 08:40:50
【问题描述】:

我从 Bernat 的博客 rails 迷你教程中获取了 cmets 代码

我尝试使用他的 best_in_place gem 添加就地编辑功能。在大多数情况下它工作正常

我的代码部署在 http://falling-spring-3964.herokuapp.com/comments

你可以看这里的代码 https://github.com/sunnygill/commentsapp

问题:

  • 我添加了一条新评论。它完美地显示在页面顶部,但名称的就地编辑不起作用
  • 如果我刷新页面,然后在节奏编辑作品中

问题:

如何在不刷新页面的情况下进行就地编辑

【问题讨论】:

    标签: jquery ruby-on-rails edit-in-place


    【解决方案1】:

    我遇到了同样的问题,我的解决方法是在create.js.erb文件中添加$('.best_in_place').best_in_place();

    【讨论】:

      【解决方案2】:

      这是因为在完成 ajax 调用后,您没有将 in-line-edit javascript 插件连接到新创建的 HTML 元素(保持名称可编辑)。我试图在 Github 上查看你的源代码,但它看起来已经过时了。

      【讨论】:

        【解决方案3】:

        您的控制器没有响应更新方法的 JSON。修复起来非常简单:只需在更新操作中添加如下内容即可。

        def update
          ...
          respond_to do |format|
            format.html { redirect_to @user}
            format.json { render json: @user }
          end
          ...
        end
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2017-05-11
          • 2012-06-02
          • 2011-08-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2017-10-17
          • 2017-03-24
          相关资源
          最近更新 更多