如何使我的标签成为Sencha EXT JS中的超链接

时间:2013-08-27 05:36:46

标签: extjs

任何人都可以帮助我在Sencha EXT JS中将我的标签作为超链接。

4 个答案:

答案 0 :(得分:1)

以下是您的问题的解决方案:[Sencha EXT JS中的超链接]:how to create hyper link in extjs4?

或者您可以为标签添加新事件:

Ext.onReady(function() {

    var yourLabel = new Ext.form.Label({
        id:'yourLabel',
        text: 'http://your-link-here.com',
        renderTo : document.body                                

    });

    Ext.getCmp('yourLabel').getEl().on('click',function(){
        window.open("http://your-link-here.com");
    });
});

答案 1 :(得分:1)

您可以告诉fieldLabel是一个链接http://jsfiddle.net/EsppR/1/

Ext.create('Ext.form.Panel', {
    title: 'Contact Info',
    renderTo: Ext.getBody(),
    items: {
        xtype: 'textfield',
        name: 'name',
        fieldLabel: '<a href="http://www.google.com">Name</a>',
        allowBlank: false  // requires a non-empty value
    }
});

答案 2 :(得分:0)

作为插件:

Ext.define('YourCompany.plugins.LinkedLabel', {
    extend: 'Ext.AbstractPlugin',
    url: undefined,
    init: function (cmp) {
        this.setCmp(cmp);
        cmp.beforeLabelTextTpl = '<a href="' + url + '">';
        cmp.afterLabelTextTpl = '</a>';
    });
});

使用:

{
    xtype: 'textfield',
    fieldLabel: 'Linked label',
    plugins: Ext.create('YourCompany.plugins.LinkedLabel', { url: '/yourUrl' })
}

答案 3 :(得分:0)

两种方式:

//1st - set html for label
{
   xtype: "label",
   html: "bla bla?! <a href='http:/\tiny.cc/snir' target='_blank'>Press This Link!!!</a><br>"
},

//2nd - create a new component
{
   xtype: 'component',
   autoEl: {
      tag: 'a',
      href: 'http:\/tiny.cc/snir/',
      target: '_blank',
      html: 'tiny.cc/snir'
   }
}

您可以在此处查看我的示例https://fiddle.sencha.com/#view/editor&fiddle/1kqh并检查不同的内容。