Add Panel with Components

In the code below, I have searchResults which is a set of Panels. I have manually created the first three panels, and I want to dynamically add subsequent panels. Once I move to the second panel, I trigger this.addPanel() to create the 4th panel. When I'm transitioning through panels, the 4th panel is there with content "Test 4". However, anytime I try to refer to the panel using the name "searchName4", it says it is undefined. Is there something below when creating that new panel that it doesn't like. I assumed using name: sN would create that component with the searchName4 bound to it. Any ideas? Thanks!

addPanel: function() { var nP = this.$.searchResults.getPanels().length+1; var sN = "searchName"+nP; var sp = this.$.searchResults; var p = sp.createComponent({ style: "width: 250px; height: 65px; background-color: lightblue", components: [ {kind: "FittableRows", style: "font-size: 12px", components: [ {name: sN, style: "font-weight: bold;", content: "Test "+nP}, ]} ] }); p.render(); alert(this.$.searchName3.setContent('test')); this.$[sN].setContent(searchDetail[nP-1].name);

Comments

  • try setting the owner of the control to this.
    var p = sp.createComponent({
    			style: "width: 250px; height: 65px; background-color: lightblue", components: [
    				{kind: "FittableRows", style: "font-size: 12px", components: [
    					{name: sN, style: "font-weight: bold;", content: "Test "+nP},
    				]}
    			]
    		}, {owner: this});
  • chris, that did the trick! thanks!
Sign In or Register to comment.