nifCody
nifCody

Reputation: 2444

Ruby on Rails (Rails 2.3.2) f.select onchange() event is not triggered in jQuery

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

Answers (1)

jithya
jithya

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

Related Questions