// NewStringValueNodeTexter returns a new instance of StringValueNodeTexter. func NewStringValueNodeTexter(node *viewmodel.StringValueNode, listener ViewModelListener) *StringValueNodeTexter { texter := &StringValueNodeTexter{ node: node, onDetailChanged: NullDetailChangeCallback} node.Subscribe(func(string) { listener.OnMainDataChanged() texter.onDetailChanged() }) return texter }
func (filler *viewModelFiller) StringValue(node *viewmodel.StringValueNode) { observable := ko.NewObservable(node.Get()) filler.object = js.Global.Get("Object").New() filler.object.Set("type", "string") filler.object.Set("label", node.Label()) filler.object.Set("readonly", !node.Editable()) filler.object.Set("data", observable.ToJS()) node.Subscribe(func(newValue string) { if observable.Get().String() != newValue { observable.Set(newValue) } }) observable.Subscribe(func(jsValue *js.Object) { newValue := jsValue.String() if jsValue == js.Undefined { newValue = "" } if node.Get() != newValue { node.Set(newValue) } }) }