 
     value: (val = null) ->
       if val?
-        @nod.val(val)
-      @nod.val()
+        @input.val(val)
+      @input.val()
 
     clear: () ->
-      @nod.val ''+      @input.val ''

    make_readonly: () ->
      if @editable
        @nod.get(0).setAttribute('readonly', 'readonly')
        @nod.addClass 'is-readonly'
        @editable = false
        @changed 'editable'


  class pi.TextInput extends pi.Base
    initialize: ->
      @input = if @nod.get(0).nodeName.toLowerCase() is 'input' then @nod else @nod.find('input')
      @editable = true
      make_readonly if @options.readonly
      super

    make_editable: () ->
      if not @editable
        @input.get(0).removeAttribute('readonly') 
        @nod.removeClass 'is-readonly'
        @editable = true
        @changed 'editable'
