Sha256: 88d57782afd3876ca6cabd760a1b97ecab3f5a551de9360544e0bf67a6f2c1d4
Contents?: true
Size: 1.36 KB
Versions: 3
Compression:
Stored size: 1.36 KB
Contents
///- - - - - - - - - - - - - - - - - - - - /// FORM ITEM ///- - - - - - - - - - - - - - - - - - - - import { _FormItemEditor } from './form_item_editor' class FormItemChoice { constructor() { this.target = '.form-item--choice' } isSet() { if ( $( this.target ).length > 0 ) { return true } else { return false } } setEvents() { $(document).on('click', '.form-item--add-choice', function( event ) { event.preventDefault() // Clone the new choice field var choices = $( this ).parent('.form-item--choices') var newchoice = choices.find('.form-item--new-choice') var clone = newchoice.clone().removeClass('form-item--new-choice').toggle() clone.find('.form-item--toggle-choice').toggle() // Append the clone right after choices.prepend( clone ) // Update form item editor size _FormItemEditor.resize() }) $(document).on('click', '.form-item--delete-choice', function( event ) { event.preventDefault() var choice = $( this ).parent('.form-item--choice') var destination = $( this ).attr('href') $.ajax({ url: destination, type: 'DELETE', success: function() { choice.remove() } }) }) $(document).on('click', '.form-item--js-delete-choice', function( event ) { event.preventDefault() $( this ).parent('.form-item--choice').remove() }) } } export let _FormItemChoice = new FormItemChoice()
Version data entries
3 entries across 3 versions & 1 rubygems