Sha256: f530d3f7487649921ee403ab6390c09029c13b27dd02a0687577c818c568e412
Contents?: true
Size: 1.38 KB
Versions: 1
Compression:
Stored size: 1.38 KB
Contents
ready = -> if $('.taggable').length $('.taggable').keyup (elm) -> tags_separator = ',' # Search by last separated word tags_arr = $(elm.target).val().split(tags_separator) search_string = tags_arr[tags_arr.length - 1].trim() $.ajax url: $(@).data('tags_list_path') type: "GET" dataType: "json" data: starts_with: search_string success: (response) -> tags_list_popup(response, elm.target) tags_list_popup = (tag_list, object) -> popup_id = 'tags_popup' # Create or use existing Popup Window if $('#' + popup_id).length > 0 popup_container = $('#' + popup_id) else popup_container = $("<div id='#{popup_id}'></div>") $(object).after(popup_container) # Show tag lists html_list = $('<ul/>') $.map tag_list, (tag) -> li = $('<li/>') .addClass('ui-menu-item') .attr('role', 'menuitem') .appendTo(html_list) a = $('<a/>') .addClass('ui-all') .text(tag.name) .appendTo(li) a.click -> already_filled_in_tags = $(object).val().split(',') already_filled_in_tags.pop() already_filled_in_tags.push(tag.name + ', ') $(object).val(already_filled_in_tags.join(', ')) # Destroy popup after select tag popup_container.remove() popup_container.html(html_list) $(document).ready(ready) $(document).on('page:load', ready)
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
my_tags-0.0.9 | app/assets/javascripts/my_tags/my_tags.js.coffee |