新建问题-主题-autocomplete-选中跳转

This commit is contained in:
ganyiang 2014-05-07 20:30:42 +08:00
parent 9b151567f1
commit 786481e144
4 changed files with 9 additions and 3 deletions

View File

@ -30,6 +30,7 @@ class AutoCompletesController < ApplicationController
@issues.compact! @issues.compact!
end end
render :layout => false render :layout => false
end end
private private

View File

@ -3,5 +3,5 @@
'label' => "#{issue.tracker} ##{issue.id}: #{truncate issue.subject.to_s, :length => 60}", 'label' => "#{issue.tracker} ##{issue.id}: #{truncate issue.subject.to_s, :length => 60}",
'value' => issue.id 'value' => issue.id
} }
}.to_json }.to_json
%> %>

View File

@ -14,7 +14,8 @@
<% if @issue.safe_attribute? 'tracker_id' %> <% if @issue.safe_attribute? 'tracker_id' %>
<p><%= f.select :tracker_id, @issue.project.trackers.collect {|t| [t.name, t.id]}, {:required => true}, <p><%= f.select :tracker_id, @issue.project.trackers.collect {|t| [t.name, t.id]}, {:required => true},
:onchange => "updateIssueFrom('#{escape_javascript project_issue_form_path(@project, :id => @issue, :format => 'js')}')" %></p> :onchange => "updateIssueFrom('#{escape_javascript project_issue_form_path(@project, :id => @issue, :format => 'js')}')" %></p>
<% end %> <% end %>

View File

@ -476,12 +476,16 @@ function observeAutocompleteField(fieldId, url, options) {
$(document).ready(function() { $(document).ready(function() {
$('#'+fieldId).autocomplete($.extend({ $('#'+fieldId).autocomplete($.extend({
source: url, source: url,
select: function(e,ui){location.href("/issues/"+ui.item.value);},
minLength: 2, minLength: 2,
search: function(){$('#'+fieldId).addClass('ajax-loading');}, search: function(){$('#'+fieldId).addClass('ajax-loading');},
response: function(){$('#'+fieldId).removeClass('ajax-loading');} response: function(){$('#'+fieldId).removeClass('ajax-loading');
}
}, options)); }, options));
$('#'+fieldId).addClass('autocomplete'); $('#'+fieldId).addClass('autocomplete');
}); });
} }
function observeSearchfield(fieldId, targetId, url) { function observeSearchfield(fieldId, targetId, url) {