$ -> # Define editor behavior for multienum attributes. scrivito.on 'editing', -> template = (values) -> element = $('') .attr('multiple', 'true') .addClass('form-control') $.each values, (index, value) -> $('') .attr('value', value) .text(value) .appendTo(element) element save = (event) -> element = $(event.currentTarget) cmsField = element.data('cmsField') content = element.val() cmsField.scrivito('save', content).done -> cmsField.trigger('scrivito_reload') $(document).on 'click', '[data-scrivito-field-type="multienum"]:not([data-editor]), [data-editor="multienum"]', (event) -> cmsField = $(event.currentTarget) selected = cmsField.scrivito('content') values = cmsField.data('values') template(values) .data('cmsField', cmsField) .val(selected) .insertAfter(cmsField) .focusout(save) .focus() cmsField.hide()