Explorar el Código

fix: setting and getting value of textarea when enable codemirror

wangweimin hace 4 años
padre
commit
af5aa956a6
Se han modificado 1 ficheros con 7 adiciones y 0 borrados
  1. 7 0
      webiojs/src/models/input/textarea.ts

+ 7 - 0
webiojs/src/models/input/textarea.ts

@@ -69,11 +69,18 @@ export class Textarea extends InputItem {
 
 
     update_input(spec: any) {
     update_input(spec: any) {
         let attributes = spec.attributes;
         let attributes = spec.attributes;
+        if (this.code_mirror && 'value' in attributes) {
+            this.code_mirror.setValue(attributes['value']);
+            delete attributes['value'];
+        }
 
 
         this.update_input_helper.call(this, -1, attributes);
         this.update_input_helper.call(this, -1, attributes);
     };
     };
 
 
     get_value() {
     get_value() {
+        if (this.code_mirror)
+            return this.code_mirror.getValue();
+
         return this.element.find('textarea').val();
         return this.element.find('textarea').val();
     };
     };