       return
 
   getStateIndex:(name)->
+
     {states} = @getOptions()
     unless name
       return 0

    @setCallback states[index + 1].bind @, @toggleState.bind @

  toggleState:(err)->
    {states} = @getOptions()
    nextState = states[@stateIndex + 2] or states[0]
    unless err

  triggerClick:()-> @doOnSubmit()

class KDToggleButton extends KDButtonView

  constructor:(options = {},data)->

    options = $.extend
      dataPath : null          # a JsPath String
      states   : []            # an Array of Objects in form of stateName : callback key/value pairs
