2013-10-14 36 views
1

我有這樣的代碼中的Rails 2.X:傳遞散列鍵向控制器

<div class="label-field-pair"> 
    <label><%= t('select_a_course_batch') %></label> 
    <div class="text-input-bg"> <%= select :fees_submission, :batch_id, @batches.map { |c| [c.full_name, c.id] }, 
     {:prompt => "#{t('select_a_batch')}"}, 
     {:onChange => "#{remote_function(:url => {:action => "update_fees_collection_dates_voucher"}, :with => "'batch_id='+value")}"}%> </div> 

爲的onChange動作。我想通過散列密鑰(c.fullname)到遠程控制器update_fees_collection_dates_voucher代替散列值(c.id)..用''batch_id ='+ key「替換''batch_id ='+ value」似乎不起作用。有任何想法嗎?謝謝!

回答

0

這不是工作?

{:onChange => "#{remote_function(:url => {:action => "update_fees_collection_dates_voucher"}, :with => "'batch_id='+ $(this).html()}"}%> 
+0

試過但沒有工作..我不知道$(this).html()會轉換成散列鍵..你能詳細說明它是如何工作的嗎? THanks .. – haanimasood

+0

哪個JS庫你使用的是原型還是jQuery? – techvineet

+0

原型...。 – haanimasood