Roo/Template.js
[roojs1] / Roo / JsonView.js
index 620a811..c4ff719 100644 (file)
  * @extends Roo.View
  * Shortcut class to create a JSON + {@link Roo.UpdateManager} template view. Usage:
 <pre><code>
-var view = new Roo.JsonView("my-element",
-    '&lt;div id="{id}"&gt;{foo} - {bar}&lt;/div&gt;', // auto create template
-    { multiSelect: true, jsonRoot: "data" }
-);
+var view = new Roo.JsonView({
+    container: "my-element",
+    tpl: '&lt;div id="{id}"&gt;{foo} - {bar}&lt;/div&gt;', // auto create template
+    multiSelect: true, 
+    jsonRoot: "data" 
+});
 
 // listen for node click?
 view.on("click", function(vw, index, node, e){
@@ -35,7 +37,9 @@ var tpl = new Roo.Template(
     "&lt;/div&gt;&lt;hr /&gt;"
 );
 
-var moreView = new Roo.JsonView("entry-list", tpl, {
+var moreView = new Roo.JsonView({
+    container :  "entry-list", 
+    template : tpl,
     jsonRoot: "posts"
 });
 moreView.on("beforerender", this.sortEntries, this);
@@ -45,14 +49,20 @@ moreView.load({
     text: "Loading Blog Entries..."
 });
 </code></pre>
+* 
+* Note: old code is supported with arguments : (container, template, config)
+* 
+* 
  * @constructor
  * Create a new JsonView
- * @param {String/HTMLElement/Element} container The container element where the view is to be rendered.
- * @param {Template} tpl The rendering template
+ * 
  * @param {Object} config The config object
+ * 
  */
-Roo.JsonView = function(container, tpl, config){
-    Roo.JsonView.superclass.constructor.call(this, container, tpl, config);
+Roo.JsonView = function(config, depreciated_tpl, depreciated_config){
+    
+    
+    Roo.JsonView.superclass.constructor.call(this, config, depreciated_tpl, depreciated_config);
 
     var um = this.el.getUpdateManager();
     um.setRenderer(this);
@@ -86,8 +96,7 @@ Roo.JsonView = function(container, tpl, config){
 };
 Roo.extend(Roo.JsonView, Roo.View, {
     /**
-     * The root property in the loaded JSON object that contains the data
-     * @type {String}
+     * @type {String} The root property in the loaded JSON object that contains the data
      */
     jsonRoot : "",
 
@@ -147,7 +156,7 @@ Roo.extend(Roo.JsonView, Roo.View, {
             o = Roo.util.JSON.decode(response.responseText);
             if(this.jsonRoot){
                 
-                o = /** eval:var:o */ eval("o." + this.jsonRoot);
+                o = o[this.jsonRoot];
             }
         } catch(e){
         }