ruby-on-rails
  • ruby-on-rails-3
  • ruby-on-rails-3.1
  • ruby-on-rails-plugins
  • twitter-bootstrap
  • 2012-03-18 6 views 5 likes 
    5

    基本的には、自分のプロファイル情報を編集できるように、私のrails webappでbest_in_placeを使用しています。best_in_placeをtwitterのブートストラップからの先読みで使用することはできますか?

    <p>College/University: <input type="text" class="span3" style="margin: 0 auto;" data-provide="typeahead" data-items="8" data-source='["University of Pennsylvania","Harvard","Yale","Princeton","Cornell","Brown","Columbia","Dartmouth"]'></p> 
    

    これは私の先行入力と作業フォームのボックスを与える:事はここに私が働いているものだ..私は、ユーザーが特定のエントリのための先行入力フォームを提示することを希望、です。しかし、私は彼らがテキストをクリックすると、ユーザーが唯一の先行入力フォームが表示されるように、そして箱から離れてクリックするか、選択があるEnterキーを押す時に

    <%= best_in_place @student, :education %> 
    

    のようなものでbest_in_placeでこれを包むことができるようにしたいですデータベースに格納される。

    これを行うには比較的簡単な方法はありますか?

    +1

    リファレンスhttp://stackoverflow.com/questions/14796415/how-to-use-best-in-place-with-twitter-bootstrap –

    答えて

    0

    best_in_placeのような任意のRuby on railヘルパーメソッドでは、:html_attrsオプションを追加することができます。あなたの見た目のサンプルは次のとおりです。

    <%= best_in_place @student, :education, :type=> :input, 
        :html_attrs => {:'data-provide' => "typeahead", // Any other attributes 
            :'data-source' => '["University of Pennsylvania","Harvard","Yale","Princeton","Cornell","Brown","Columbia","Dartmouth"]' %> 
    

    希望します。

    関連する問題