I have a few select elements in my views that are supposed to fire after the user chooses an item from the dropdown.
My selects look like this:
<%= collection_select(:project, :id, projects, 'id', 'name', { },{:style => "width:150px", :onchange => "document.getElementById('project_btn').click()" }) %>
<span class="control_button_light" style="display:none;"><%= submit_tag 'jump_to_project', :id => "project_btn" %></span>
<%= observe_field("project_id", :frequency => 1, :function => "document.getElementById('project_btn').click()") %>
The problem is that the observe_field function is firing before the select loses focus. In other words, the submit element is "clicked" 1 second after the select gets focus, even if the user hasn't finished choosing from the dropdown.
Anyone know how to delay the observer from clicking the submit until after the select loses focus?