PDA

View Full Version : about html tag in viewport



yog
14 Jul 2009, 6:10 AM
var viewport=new Ext.Viewport({

layout: 'border',
renderTo:Ext.getBody(),
items:[{

region: 'north',
//xtype:'panel',
//title:'Solar',
id:'north',
height:110,
collapsible:false,
//autoLoad:{url:'test.jsp'},
//scripts:true,
html: '<html><script> alert("You clicked the button");</script>'

is it possible to write script inside above html tag ??

Animal
14 Jul 2009, 6:22 AM
No.

What's the point?

yog
14 Jul 2009, 6:28 AM
i want to calll anchor on onclick event so that i m doing this things

Condor
14 Jul 2009, 6:30 AM
i want to calll anchor on onclick event so that i m doing this things

You'll have to explain better...

yog
14 Jul 2009, 6:33 AM
ok
i have some html content in north panel and i also have some anchors on which i calling onclick event so that the respective link should be opened in center panel. how should i do that one.
I m using viwport

Animal
14 Jul 2009, 6:46 AM
Use a click listener on that element.

Condor
14 Jul 2009, 6:53 AM
Ahh... So you want to intercept anchor click.

Example:

autoLoad: {
url:'test.jsp',
// call after file is loaded
callback: function(el){
// select all anchor tags
el.select('a').each(function(a){
// add a click event to each anchor
a.on('click', function(){
// load the original href in the center panel body
var href = this.dom.href;
var center = Ext.getCmp('center');
center.body.load({url: href});
// stops the click event (so it doesn't follow the href)
}, a, {stopEvent: true});
});
}
}

Animal
14 Jul 2009, 6:54 AM
Personally, I'd use one listener on the element, added at page init time, and the delegate option.

yog
14 Jul 2009, 8:49 PM
thnx condor and admin its working
but how should i pass array of anchor object dynamically?

Condor
14 Jul 2009, 9:02 PM
thnx condor and admin its working
but how should i pass array of anchor object dynamically?

Again, you'll have to explain better...

yog
15 Jul 2009, 2:01 AM
autoLoad: {
url:'test.jsp',
// call after file is loaded
callback: function(el){
alert('Just For Fun'+Ext.get('aTag'));
// select all anchor tags
el.select('a').each(function(a){
// add a click event to each anchor
a.on('click', function(){
// load the original href in the center panel body
//alert('Just For Fun');
var href = '../login/form/frmDispDateLog2.jsp';
var center = Ext.getCmp('tabpanel');
center.body.load({url: href});
//add tab in center panel
addTab(center,href);
// stops the click event (so it doesn't follow the href)
}, a, {stopEvent: true});
});
}
}


In above code i m all anchors are called from test.jsp but i need the anchor array eg. i have four no of array on test.jsp page if i click on first array respective link should be opened in center panel above code i m displaying is in north panel.
how it would be called?

Condor
15 Jul 2009, 2:31 AM
So you only want to intercept specific anchors and not all?

In that case you should modify the 'a' selector to something that only matches your anchors, e.g. 'table:first a' or 'a.my-class'.

yog
15 Jul 2009, 2:47 AM
no, i have four anchors in test.jsp. for which i need anchor array and dynamically it should refer to respective url. how should i use the anchor array?

Condor
15 Jul 2009, 3:01 AM
What do you mean by 'anchor array'?

yog
15 Jul 2009, 3:14 AM
having four different anchors

Condor
15 Jul 2009, 3:26 AM
el.select('a').items would return the array of 4 anchors. But what are you planning on doing with this array?

yog
15 Jul 2009, 3:33 AM
i have links i.e. anchors on north panel. on click of any of four link respecive url should be opened in center panel

Condor
15 Jul 2009, 3:42 AM
But that is what my code already did!

yog
15 Jul 2009, 3:52 AM
i m not getting
pls can u elaborate it

steffenk
15 Jul 2009, 4:13 AM
i fear Condor won't answer again, as he posted the code with all the inline comments. Please read and test before asking further
"// load the original href in the center panel body"

Animal
15 Jul 2009, 4:27 AM
Condor has the patience of a saint!