PDA

View Full Version : [SOLVED] Ext.select no result



Mark
21 Jun 2010, 4:19 AM
I'tried this code with Ext.Core 3.0 but the result of var y is [object].
The same testcase with Extjs shows the correct coord.





Ext.onReady(function()
{
var el = Ext.get(document.documentElement || document.body);
var trigger = el.select('a[rel=anchor]');
trigger.on('click', function()
{
var target = this.getAttribute('href').split('#');
var anc = el.select('a[name='+target[1]+']').first();
var y = anc.getY();
console.log(y);
}
);
})here a short testcase:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<title></title>
<script type="text/javascript" src="../sources/ext3/lib/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="../sources/ext3/lib/ext-all-debug.js"></script>
<!-- <script type="text/javascript" src="../sources/ext3/core/ext-core.js"></script> -->

<script type="text/javascript">


Ext.onReady(function()
{
var el = Ext.get(document.documentElement || document.body);
var trigger = el.select('a[rel=anchor]');
trigger.on('click', function()
{
var target = this.getAttribute('href').split('#');
var anc = el.select('a[name='+target[1]+']').first();
var y = anc.getY();
console.log(y);
alert(y);

}
);
})

</script>
</head>

<body>
<p><a rel='anchor' href='#anker1' >go to anchor1</a></p>
<p><a name="anker1">Anker</a> </p>
</body>

</html>
I spend several hours on this :s, but I didn't find a solution ? Where is my fault?

Condor
21 Jun 2010, 4:36 AM
ext-core doesn't have an Ext.CompositeElementLite.first() method, so you end up with Ext.Element.first(), which is something completely different!

Use item(0) instead of first().

Mark
21 Jun 2010, 5:42 AM
Now I understand! Thank you, Condor!