Reputation: 2444
I have creating a select option on using the f.select form helper as follow
<%= f.select(:sales_type, {'Direct' => 'Direct', 'ME' => 'ME', 'Direct Staff' => 'Direct Staff'},{:onchange => "hello();"}) %>
and my JavaScript function is as follow
$(function () {
function helllo(){
alert("from hello");
}
});
while I trigger the f.select I expect the alert box should be shown. But the trigger is not triggered while I choose different options
Let me know which part I did wrong ?
Thanks in advance.
Upvotes: 0
Views: 105
Reputation: 428
<%= f.select(:sales_type, {'Direct' => 'Direct', 'ME' => 'ME', 'Direct Staff' => 'Direct Staff'},{},{:onchange => "hello();"}) %>
will work i guess. correct syntax for select is
select(method, choices = nil, options = {}, html_options = {}, &block)
Upvotes: 1