2016-01-06 87 views
1

我是新來的紅寶石,並嘗試在這裏打電話給js函數onchange,但沒有工作,沒有得到合適的答案。爲什麼我的onchange函數不能正常工作?

= f.select :amendment_type, [['Renewal','renewal'],['Lease Amendment Agreement','Lease Amendment Agreement'],['Expansion','Expansion'],['Storage','Storage'],['Parking','Parking'],['Other(for me to fill in)','Other']], class: "amendment_type input", style: "width: 450px;", onchange: "alert('hello')" 
+2

顯示呈現的HTML。 –

回答

1

select方法的參數是:

選擇(方法,選擇=零,選項= {},html_options = {},&塊)

您已經使用options針對html_options,因此您必須將您的代碼替換爲:

= f.select :amendment_type, [['Renewal','renewal'],['Lease Amendment Agreement','Lease Amendment Agreement'],['Expansion','Expansion'],['Storage','Storage'],['Parking','Parking'],['Other(for me to fill in)','Other']], {}, class: "amendment_type input", style: "width: 450px;", onchange: "alert('hello')" 
+0

以上解決方案適用於我。我衷心感謝你的幫助..... –