-1

ベストインプレースと Twitter ブートストラップで本当に厄介な問題があります。私はそれに多くの時間を費やしてきました。私はいくつかのページを調べました - best_in_place github page と Issues。だから私はそれを修正したと思ったが、修正しなかったし、間違いがどこにあるのかわからない。

最初の編集に best_in_place を使用している場合、機能し、値を保存すると、入力が新しい値で「通常の」ビューに戻ります。しかし、同じアクション(編集)を2回目に実行したい場合、機能しません。ページをリロードする必要があります。その後、もう一度編集できるのは 1 回だけです。私のコードは次のとおりです。

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 ThreadExampleAppBest_in_place Issue

誰か助けてくれませんか?おそらくTwitter Bootstrapが原因であることはわかっていますが、修正方法はわかりません:(

4

1 に答える 1

0

OK、私はその解決策を見つけました。「問題」は次の行にあります。

format.json { respond_with_bip(@account) }

私はそれを次のように置き換えました:

format.json { render json: @account}

そして、それは今働いています。しかし、それはただの運でした。ここでの主な違いは何ですか?なぜ 1 つが機能し、2 つ目が機能しないのですか? Respond_with_bip は正確には何をしますか?

于 2013-03-28T22:26:18.487 に答える