2013-12-20 15 views
4

我試着用下面這樣:如何使用Rails best_in_place更寬的文本框?

<%= current_user.first_name %> 
<%= current_user.last_name %> 
<span class="bubble"> 
    <%= best_in_place current_user, 
     :blurb, 
     type: :textarea, 
     :cols => "30", 
     :rows => "50", 
     :inner_class => 'occupation-edit', 
     nil: 'Add a short blurb (max 140)' 
    %> 
</span> 

但是,這是行不通的。是否可以使文本區域的長度與垂直長度一樣長?它似乎不是用'best_in_place'寶石定製的。

回答

6

使用html_attrs,您可以設置這些類型的參數,如:

<%= best_in_place current_user, 
     :blurb, 
     :type => :textarea, 
     :html_attrs => { :cols => '30', :rows => '50' } 
%> 

而且如果rowscols屬性不工作,你可能想嘗試的style屬性,就像這樣:

<%= best_in_place current_user, 
     :blurb, 
     :type => :textarea, 
     :html_attrs => { :style => 'width:500px; height:500px;' } 
%> 
+0

謝謝@summea這是更好的但是,cols:'30'仍然沒有使它在垂直方向更長。只有行似乎在這裏工作,我做錯了什麼? –

+0

嗨,Sonny,'cols'和'rows'似乎都可以在我的測試應用程序中工作......您可以複製/超出您使用的確切代碼行嗎? – summea

+0

當然, <%= best_in_place CURRENT_USER, :導語, :類型=>:文本區域, :html_attrs => {COLS: '5000',行: '1'}, 零:「添加短的Blurb(最大140)'%> –

相關問題