   # Updates the binding's model from what is currently set on the view. Unbinds
   # the old model first and then re-binds with the new model.
   update: (models = {}) =>
-    @model = @observer.target
+    @model = @observer?.target
     @unbind()
     @binder.update?.call @, models
     @bind()


  # Syncs up the view binding with the model.
  sync: =>
    if @model isnt @observer.target
      observer.unobserve() for observer in @dependencies
      @dependencies = []

      if (@model = @observer.target)? and @options.dependencies?.length
        for dependency in @options.dependencies
          observer = @observe @model, dependency, @sync
          @dependencies.push observer

    @set @observer.value()

  # Publishes the value currently set on the input element back to the model.
  publish: =>
    value = Rivets.Util.getInputValue @el

    for formatter in @formatters.slice(0).reverse()
      args = formatter.split /\s+/
      id = args.shift()

      if @view.formatters[id]?.publish
        value = @view.formatters[id].publish value, args...

    @observer.setValue value

  # Subscribes to the model for changes at the specified keypath. Bi-directional
  # routines will also listen for changes on the element to propagate them back
  # to the model.
  bind: =>
    @binder.bind?.call @, @el
    @observer = @observe @view.models, @keypath, @sync
    @model = @observer.target

    if @model? and @options.dependencies?.length
      for dependency in @options.dependencies

  # Unsubscribes from the model and the element.
  unbind: =>
    @binder.unbind?.call @, @el
    @observer?.unobserve()

    observer.unobserve() for observer in @dependencies
    @dependencies = []
