%= error_messages_for 'time_entry' %>
<%= javascript_tag do %> $(document).ready(function(){ $('#stopwatch_time_entry_project_id').change(function(){ $('#stopwatch_time_entry_issue_id').val(''); }); $('#stopwatch_time_entry_project_id, #stopwatch_time_entry_issue_id').change(function(){ $.ajax({ url: '<%= j update_form_stopwatch_timers_path(time_entry_id: @time_entry.id, format: 'js') %>', type: 'post', data: $(this).closest('form').serialize() }); }); }); observeAutocompleteField('stopwatch_time_entry_issue_id', function(request, callback) { var url = '<%= j auto_complete_issues_path %>'; var data = { term: request.term }; var project_id; <% if @time_entry.new_record? && @project %> project_id = '<%= @project.id %>'; <% else %> project_id = $('#stopwatch_time_entry_project_id').val(); <% end %> if(project_id){ data['project_id'] = project_id; } else { data['scope'] = 'all'; } $.get(url, data, null, 'json') .done(function(data){ callback(data); }) .fail(function(jqXHR, status, error){ callback([]); }); }, { select: function(event, ui) { $('#stopwatch_time_entry_issue').text(''); $('#stopwatch_time_entry_issue_id').val(ui.item.value).change(); } } ); <% end %>