PDA

View Full Version : ExtJS 4 and ASP.Net - renderTo on MasterPage



nobruds
1 Oct 2014, 7:02 AM
Hello,

I have a problem with the renderTo property while using it with asp.net master pages, and my ext js code is on a separated file. The problem is that the panel do not render.

Extjs.js


var myPanel = Ext.create('Ext.TabPanel', {
renderTo: 'myDivId',
...
});

home.aspx

<asp:Content ID="Content2" ContentPlaceHolderID="cphHeader" runat="server">
<script type="text/javascript" src="Extjs.js"></script>
</asp:Content>


<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<div id="myDivId">
</div>
</asp:Content>




If i use like this, don't work but if put my all the javascript code inside the script tag on the aspx file, works just fine.


<script type="text/javascript">
var myPanel = Ext.create('Ext.TabPanel', {
renderTo: 'myDivId',
...
});
</script>

Someone knows this problem ? renderTo is not finding my DIV by the ID if the code is not on the same file, how can I resolve this ?

thanks

slemmon
14 Oct 2014, 2:35 AM
Are you creating your panel inside of:



Ext.onReady(function () {
// Create the panel and render it to the target div
});


or within the launch method of Ext.application()?



Ext.application({
name: 'MyApp',
launch: function () {
// Create the panel and render it to the target div
}
});


If not, you'll need to so that the render action doesn't happen until the DOM has been rendered out.

nobruds
14 Oct 2014, 7:31 AM
Hello. thanks for the reply

Yes, its is inside the Ext.onReady.

The problem is, if all my javascript code is in the same file as the HTL is, works, but if I separate my JS from the file, doesn't work. maybe loses reference, idk.

nobruds
4 Nov 2014, 8:39 AM
Hello .. I can't fix this, anyone can help ? thanks