javascript - Adding a listener to hyperlink in ExtJS - Stack Overflow

I simply want to add a hyper link in my application. I tried the following code and the link is appeari

I simply want to add a hyper link in my application. I tried the following code and the link is appearing in the page. But the on click event is not working. Can anyone please tell me what might be the reason?

xtype:'box',
isFormField: true,
id: "prospectStageLink",
style: "padding: 3px",
autoEl:{
    //html: '&nbsp;<a href>Link To Prospect</a>'
    tag: 'a',
    href: '#',
    cn: 'Link To Prospect'
},
listeners: {
    render: function(c){
        c.on('click', function(e){
            alert('clicked', 'hiii');
        }, c, { stopEvent: true });
    }
}

I simply want to add a hyper link in my application. I tried the following code and the link is appearing in the page. But the on click event is not working. Can anyone please tell me what might be the reason?

xtype:'box',
isFormField: true,
id: "prospectStageLink",
style: "padding: 3px",
autoEl:{
    //html: '&nbsp;<a href>Link To Prospect</a>'
    tag: 'a',
    href: '#',
    cn: 'Link To Prospect'
},
listeners: {
    render: function(c){
        c.on('click', function(e){
            alert('clicked', 'hiii');
        }, c, { stopEvent: true });
    }
}
Share Improve this question edited Nov 18, 2011 at 11:21 Chau 5,5709 gold badges67 silver badges99 bronze badges asked Nov 18, 2011 at 9:36 spvspv 751 silver badge9 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 2

try this :

listeners: {
    render: function(ponent) {
        ponent.getEl().on('click', function(e) {
            alert('test');
        });    
    }
}

I assume you are not running on ExtJS 4, because BoxComponent was removed from it.

Anyways, the simple explanation is probably that BoxComponent does not have a click event. You might want to try using an Element instead, which does have support for the click event.

xtype:'box',
isFormField: true,
id: "prospectStageLink",
style: "padding: 3px",
autoEl:{
    //html: '&nbsp;<a href>Link To Prospect</a>'
    tag: 'a',
    href: '',
    onClick: 'nameYouFunction'
}

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745511092a4630774.html

相关推荐

  • javascript - Adding a listener to hyperlink in ExtJS - Stack Overflow

    I simply want to add a hyper link in my application. I tried the following code and the link is appeari

    20小时前
    50

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信