JsRender/Roo.js
authorEdward <edward@roojs.com>
Tue, 29 Apr 2014 09:01:25 +0000 (17:01 +0800)
committerEdward <edward@roojs.com>
Tue, 29 Apr 2014 09:01:25 +0000 (17:01 +0800)
JsRender/Roo.js

index 47fa938..3177043 100644 (file)
@@ -509,6 +509,50 @@ Roo = XObject.define(
              
              
              
+        },
+        
+        toSourceModal : function(isPreview) 
+        {
+            
+            isPreview = isPreview || false;
+            var items = JSON.parse(JSON.stringify(this.items[0]));
+            var o = this.mungeToString(items, false, '            ');   
+            return [
+                this.outputHeader(),
+                this.name + " = {",
+                "",
+                "    dialog : false,",
+                "    callback:  false,",
+                "",   
+                "    show : function(data, cb)",
+                "    {",
+                "        if (!this.dialog) {",
+                "            this.create();",
+                "        }",
+                "",
+                "        this.callback = cb;",
+                "        this.data = data;",
+                "        this.dialog.show(this.data._el);",
+                "        if (this.form) {",
+                "           this.form.reset();",
+                "           this.form.setValues(data);",
+                "           this.form.fireEvent('actioncomplete', this.form,  { type: 'setdata', data: data });",
+                "        }",
+                "",   
+                "    },",
+                "",
+                "    create : function()",
+                "    {",
+                "        var _this = this;",
+                "        this.dialog = Roo.factory(" + o +  ");",
+                "    }",
+                "};",
+                ""
+                
+             ].join("\n");
+             
+             
+             
         },