mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-18 16:20:12 +01:00
Tag autocomplete
This commit is contained in:
parent
bfc6189611
commit
01e4cdb178
3 changed files with 6 additions and 0 deletions
|
|
@ -247,6 +247,10 @@ module TodosHelper
|
|||
array_or_string_for_javascript( current_user.contexts.collect{|c| escape_javascript(c.name) } )
|
||||
end
|
||||
|
||||
def tag_names_for_autocomplete
|
||||
array_or_string_for_javascript( Tag.all.collect{|c| escape_javascript(c.name) } )
|
||||
end
|
||||
|
||||
def default_contexts_for_autocomplete
|
||||
projects = current_user.projects.find(:all, :conditions => ['default_context_id is not null'])
|
||||
Hash[*projects.map{ |p| [p.name, p.default_context.name] }.flatten].to_json
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
var projectNames = <%= project_names_for_autocomplete %>;
|
||||
var defaultContexts = <%= default_contexts_for_autocomplete %>;
|
||||
var defaultTags = <%= default_tags_for_autocomplete %>;
|
||||
var tagNames = <%= tag_names_for_autocomplete %>;
|
||||
<% end -%>
|
||||
</script>
|
||||
<link rel="shortcut icon" href="<%= url_for(:controller => 'favicon.ico') %>" />
|
||||
|
|
|
|||
|
|
@ -265,6 +265,7 @@ function enable_rich_interaction(){
|
|||
$('input[name=context_name]').autocomplete(contextNames);
|
||||
$('input[name=project[default_context_name]]').autocomplete(contextNames);
|
||||
$('input[name=project_name]').autocomplete(projectNames);
|
||||
$('input[name=tag_list]').autocomplete(tagNames, {multiple: true,multipleSeparator:','});
|
||||
|
||||
/* have to bind on keypress because of limitataions of live() */
|
||||
$('input[name=project_name]').live('keypress', function(){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue