app/assets/javascripts/formagic/inputs/markdown.coffee in formagic-0.3.0 vs app/assets/javascripts/formagic/inputs/markdown.coffee in formagic-0.3.1
- old
+ new
@@ -31,10 +31,12 @@
# PRIVATE ===============================================
_add_input: ->
if @config.htmlFieldName
@$inputHtml =$ "<input type='hidden' name='[#{ @config.htmlFieldName }]' />"
+ if @object
+ @$inputHtml.val(@object[@config.htmlFieldName])
@$el.append @$inputHtml
@$input =$ "<input type='hidden' name='#{ @name }' value='#{ @_safe_value() }' />"
@$el.append @$input
@@ -76,16 +78,23 @@
highlightActiveLine: false
showPrintMargin: false
@session.on 'change', (e) => @_update_inputs()
+ @_update_inputs()
+
@config.onInitialize?(this)
updateValue: (@value) ->
@session.setValue(@value)
@_update_inputs()
+
+ hash: (hash={}) ->
+ hash[@config.htmlFieldName] = @$inputHtml.val()
+ hash[@config.klassName] = @$input.val()
+ return hash
chr.formInputs['markdown'] = InputMarkdown