Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

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
You can’t perform that action at this time.