【发布时间】:2013-03-28 07:43:03
【问题描述】:
我对最佳位置和 Twitter 引导程序有一个非常烦人的问题。我已经花了很多时间。我已经浏览了好几页 - best_in_place github 页面和问题。所以我想,我修复了它但没有,我不知道错误在哪里。
当我使用 best_in_place 进行第一次编辑时,它会起作用,保存值并将输入更改回具有新值的“正常”视图。但是当我想第二次做同样的动作(编辑它)时,它不起作用。我必须重新加载页面,然后我只能再次编辑它一次。我的代码如下:
AccountsController.rb
def update
@account = current_user.account
respond_to do |format|
if @account.update_attributes(params[:account])
format.json { respond_with_bip(@account) }
else
format.json { respond_with_bip(@account) }
end
end
end
查看
<%= best_in_place current_user.account, :introduction, :type=> :input,
:nil => "Click me to add your introduction!",
:html_attrs => {:'data-provide' => "typeahead" } %>
account.js.coffee
jQuery ->
$('.best_in_place').best_in_place()
我已经看过这个页面,但没有找到答案: SO Thread、ExampleApp、Best_in_place Issue
请问,有人可以帮我吗?我知道这可能是由 Twitter Bootstrap 引起的,但我不知道如何解决它:(
【问题讨论】:
-
输入框第二次到位了吗?
-
我找到了答案。请检查下面的答案。
-
这不是 twitter bootstrap 造成的。所有引导程序所做的就是将样式应用于元素。基于 Rails 4 和 Bootstrap 3,您需要
respond_with_ip(@object)才能使其工作。 -
这是 2.5 岁的问题。我认为这个评论无关紧要
标签: ruby-on-rails-3 twitter-bootstrap bootstrap-typeahead best-in-place