Skip to content

Instantly share code, notes, and snippets.

@fgrehm
Created February 19, 2013 18:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fgrehm/4988391 to your computer and use it in GitHub Desktop.
Save fgrehm/4988391 to your computer and use it in GitHub Desktop.
Cocoon + Chosen
jQuery ($) ->
$('.add_fields').each ->
$this = $(this)
insertionNode = $this.data('association-insertion-node')
insertionTraversal = $this.data('association-insertion-traversal')
if (insertionNode)
if (insertionTraversal)
insertionNode = $this[insertionTraversal](insertionNode)
else
insertionNode = insertionNode == "this" ? $this : $(insertionNode)
else
insertionNode = $this.parent()
insertionNode.bind 'cocoon:after-insert', (e, newContent) ->
newContent.find('.chzn-select').chosen()
@kaoussi
Copy link

kaoussi commented Jul 30, 2017

Thank you so much Man :D it saved the day for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment