Skip to content

Instantly share code, notes, and snippets.

@sevenseacat
Created October 22, 2013 03:09
Show Gist options
  • Save sevenseacat/7094609 to your computer and use it in GitHub Desktop.
Save sevenseacat/7094609 to your computer and use it in GitHub Desktop.
$(document).on 'ajax:success', '#contact_details a', (xhr, data) ->
$('#contact_details').html(data.details)
setupJobTagger = ->
$('#job_tag_list').select2
tags: []
ajax:
url: $('#job_tag_list').data('url')
dataType: 'json',
results: (data, page) ->
{ results: data }
data: (term, page) ->
{ q: term }
initSelection: (element, callback) ->
data = $(element.val().split(", ")).map (string) -> {id: String(this), name: String(this)}
callback($.makeArray data)
formatResult: (item) ->
item.name
formatSelection: (item) ->
item.name
id: (item) ->
item.name
createSearchChoice: (item) ->
{ id: item, name: item }
$(document).on 'page:load', setupJobTagger
$(document).ready setupJobTagger
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment