 
     @model.set Formbuilder.options.mappings.OPTIONS, options
     @model.trigger "change:#{Formbuilder.options.mappings.OPTIONS}"
+
+    # let's focus on the newly added element...
+    targetSlot = 1 * (if i > -1 then i + 1 else options.length - 1)
+    ($(".edit-response-field .sortableParentContainer .option .option-label-input")[targetSlot]).focus()
+
     @forceRender()
 
   removeOption: (e) ->
     $el = $(e.currentTarget)
     index = @$el.find(".js-remove-option").index($el)
+    @removeOptionAtIndex(index)
+
+  removeOptionAtIndex: (index) ->
     options = @model.get Formbuilder.options.mappings.OPTIONS
     options.splice index, 1
     @model.set Formbuilder.options.mappings.OPTIONS, options

emptyOrWhitespaceRegex = RegExp(/^\s*$/)

class FormbuilderModel extends Backbone.DeepModel
  sync: -> # noop

    'click .js-remove-option': 'removeOption'
    'click .js-default-updated': 'defaultUpdated'
    'input .option-label-input': 'forceRender'
    'keydown .option-label-input': 'handleSpecialKeysDuringOptionEditing'

  handleSpecialKeysDuringOptionEditing: (evt) ->
    if true and (evt.which == DELETE_KEYCODE or evt.keyCode == DELETE_KEYCODE)
      currLabel = evt.currentTarget.value
      if (currLabel == "")
        deletionIndex = $(evt.currentTarget).parent().index()
        @removeOptionAtIndex deletionIndex

        # focus on another option
        focusIndex = (if deletionIndex == 0 then 0 else deletionIndex - 1)
        newFocusFields = $(".edit-response-field .sortableParentContainer .option .option-label-input")
        if (newFocusFields.length > 0)
          (newFocusFields[focusIndex]).focus()

        return false
    else if evt.which == ENTER_KEYCODE or evt.keyCode == ENTER_KEYCODE
      @addOption evt

    # console.log evt
    # console.log this

  initialize: (options) ->
    {@parentView} = options
