Reputation: 1161
I'm trying to test an onchange event and i tried a lot of things and none seems do have any effect, can you guys tell me why isn't this working? Also i went to check the source code of the year of birth select and i get this:
<select id="account_year_Of_Birth" name="account[year_Of_Birth]"><option value=""></option>
I also tried with that id but again, nothing...
In my view:
<div class="control-group">
<%= f.label "Date of Birth (YYYY-MM-DD)", :class => 'control-label' %>
<div class="controls">
<%= f.select :year_Of_Birth , options_for_select((Time.now.year - 100)..(Time.zone.now.year )), :include_blank => true, :id => "year"%>
<%= f.select :month_Of_Birth, 1..12 , :include_blank=> true, :id => "month" %>
<%= f.select :day_Of_Birth, 1..31 , :include_blank => true, :id => "day" %>
</div>
<%= error_span(@account[:year_Of_Birth]) %>
</div>
In my application.js:
$( "account_year_Of_Birth" ).on('change',function() {
alert( "alert" );
});
Upvotes: 0
Views: 35
Reputation: 2916
You need a '#' in your selector:
$( "#account_year_Of_Birth" ).on('change',function() {
alert( "alert" );
});
Upvotes: 1