PDA

View Full Version : autoLoad url and html parameters to use id.



mangamine
9 Apr 2010, 9:07 AM
hello,

how can I use the id in div tag in the following code:

.........
autoLoad: {url: "test.html", callback: this.initSearch, scope: this, scripts: true},

or

html: '<div id="div1"></div>',
.......


test.html is: <div id="div1"></div>
....


neither : var myDiv = Ext.get('div1');
nor : document.getElementById("div1");

can find the id div1 !!!!! ????
thank you.

asp3ctus
9 Apr 2010, 9:14 AM
I didn't understood the question, my English isn't perfect ....
I understand you trying to get the component ... but their is this div declared ?

Is it in html file it self? is so you should have get it using Ext.get()
I don't get what is autoLoad have to do with ?
What xtype are you using with this property?
please give more code and i try to help my best )))

mangamine
9 Apr 2010, 11:16 AM
Ext.onReady(function(){

var SamplePanel = Ext.extend(Ext.Panel, {
width: 500,
height:250,
style: 'margin-top:15px',
bodyStyle: 'padding:10px',
renderTo: 'docbody', // <body id="docbody">
autoLoad: {url: "test.html", callback: this.initSearch, scope: this, scripts: true},
//test.html contains : <div id "div1">it's just a test</div>
// or html: '<div id "div1">it's just a test</div>', Instead of autoLoad

autoScroll: true
});


new SamplePanel({
title: 'Test'
});
// Now if I want to do something like this :

var myDiv = Ext.get('div1');
myDiv.highlight();
// or
alert(document.getElementById("div1").innerHTML);

// div1 is missed, and the code dont work.


});


how can I do to call the id div1 !!??

thank you again.

asp3ctus
10 Apr 2010, 2:25 AM
Ok ... so you have a mistaken <div id "div1">it's just a test</div> for <div id="div1">it's just a test</div>

And you need to make a func
testFunc = function() {
alert(document.getElementById("div1").innerHTML);
}

And add it to the listener for afterrender event like

new SamplePanel({
title: 'Test',
listeners : {
afterrender : function(){ testFunc(); }, scope: this}
}
});

You might have small probs with scope .. play around with firebug to call the func to see that it is working _)))

mangamine
10 Apr 2010, 11:19 PM
Thank you asp3ctus for your answer,

id="div1" is just one forgets, but I did it right in my program.

apparently when I use :

testFunc = function() {
alert(document.getElementById("div1").innerHTML);
}

with:
......
bodyStyle: 'padding:10px',
renderTo: 'docbody',
html: '<div id="div1">it's just a test</div>',
autoScroll: true
......

it work :)) ,

but not with : autoLoad: {url: "test.html", scripts: true},

Sorry, but can you tell me more about autoLoad !! I didnt find anything with firebug, maybe cause I cannot use it correctly =p.

mangamine
11 Apr 2010, 12:32 AM
I I found it :)

autoLoad: {url: "test.html", scripts: true,callback: this.testFunc,scope: this}

now it's working :p , thank you for all.