PDA

View Full Version : Problem with quote in html panel.



anpegar
31 Jan 2011, 7:50 AM
Hi,
the following expression is wrong, as I put the quotes in the url?
I tried:
'<a href="javascript:openUrl("eid","title","http://www.google.com");" >Click Me !!</a>' --> Wrong
'<a href=javascript:openUrl("eid","title","http://www.google.com"); >Click Me !!</a>' --> Wrong

var Menu = new Ext.ux.Panel({
id: 'Menu',
title: 'my Title',
layout: 'fit',
border: false,
html: '<a href="javascript:openUrl("eid","title","http://www.google.com");" >Click Me !!</a>'
});

thank's in advance.

httpdotcom
31 Jan 2011, 1:02 PM
escape your quotes inside the href config, or use apostrophes.



<a href="javascript:openUrl( 'eid','title','http://www.google.com');">click me</a>

anpegar
31 Jan 2011, 11:14 PM
httpdotcom, thank's for your reply but i tried a put apostrophes and don't work because the html tag of component Ext.ux.Panel have apostrophe.

this not work:

var Menu = new Ext.ux.Panel({
id: 'Menu',
title: 'my Title',
layout: 'fit',
border: false,
html: '<a href="javascript:openUrl('eid','title','http://www.google.com (http://www.google.com/)');" >Click Me !!</a>'
});

you can tell me a example?

thank's.

Condor
1 Feb 2011, 12:12 AM
Inline event handlers are known to leak memory. Instead, I recommend using:

var Menu = new Ext.ux.Panel({
id: 'Menu',
title: 'my Title',
layout: 'fit',
border: false,
items: [{
xtype: 'box',
autoEl: {
tag: 'a',
href: '#',
cn: 'Click Me!!'
},
listeners: {
render: function(c){
c.el.on('click', function(){
openUrl('eid','title','http://www.google.com');
}, c, {stopEvent: true});
}
}
}]
});

anpegar
1 Feb 2011, 12:35 AM
Ok Condor, is a good solution, works fine !!
Thank you very much !!

Condor
1 Feb 2011, 12:55 AM
The forum editor currently doesn't allow me to edit previous posts, so I'll post an update here:

I should have used 'mon' instead of 'on':

var Menu = new Ext.ux.Panel({
id: 'Menu',
title: 'my Title',
layout: 'fit',
border: false,
items: [{
xtype: 'box',
autoEl: {
tag: 'a',
href: '#',
cn: 'Click Me!!'
},
listeners: {
render: function(c){
c.mon(c.el, 'click', function(){
openUrl('eid','title','http://www.google.com');
}, c, {stopEvent: true});
}
}
}]
});