PDA

View Full Version : Window.contentEl Best Practice?



the_skua
10 Feb 2012, 8:43 AM
I'm popping up a window with some simple HTML on a button click. Currently, I'm cloning the div node to get the content in the Window. I had been feeding the window the id of the div directly, but it nuked my div on Window hide. So, now I'm worried that all this cloning is going to stack up. I would appreciate it if someone could advise me on the best practice with Window.contentEl. My code follows.

HTML

<div id="modelHelpText" class="x-hidden">Identify whether you are growing a spring wheat (spring planted) or winter wheat (fall planted). This selection will activate different components of the model that will customize the prediction for your crop.</div>

View

Ext.define('RiskMap.view.Models.ModelHelp', {
extend: 'Ext.window.Window',
alias: 'widget.modelhelp',
title: 'Wheat Class',
width: 250,
layout: 'fit'
});

Controller

onHelpClick: function(myB, e) {
var elem = document.getElementById('modelHelpText').cloneNode(true);
var view = Ext.widget('modelhelp');
view.contentEl = elem;
view.setPosition(myB.getPosition()[0]+30,myB.getPosition()[1]);
view.show();
},

mitchellsimoens
10 Feb 2012, 9:05 AM
Why not just get the text in it instead of cloning the node?

the_skua
10 Feb 2012, 9:08 AM
That works well. I'm new to HTML/JS, so pardon my lack of understanding some of the more standard methods for handling HTML.

mitchellsimoens
10 Feb 2012, 9:13 AM
No problem! If you would have seen me when I started off you would feel very smart :) Just keep chugging along and ask for help but don't be afraid to dive into some code and try to understand things.