Reputation: 63
Can any one please help to make my label as hyperlink in Sencha EXT JS.
Upvotes: 2
Views: 9502
Reputation: 3127
Two ways:
//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'
}
}
You can see my example here https://fiddle.sencha.com/#view/editor&fiddle/1kqh and inspect the differents.
Upvotes: 1
Reputation: 2571
As a plugin:
Ext.define('YourCompany.plugins.LinkedLabel', {
extend: 'Ext.AbstractPlugin',
url: undefined,
init: function (cmp) {
this.setCmp(cmp);
cmp.beforeLabelTextTpl = '<a href="' + url + '">';
cmp.afterLabelTextTpl = '</a>';
});
});
Use:
{
xtype: 'textfield',
fieldLabel: 'Linked label',
plugins: Ext.create('YourCompany.plugins.LinkedLabel', { url: '/yourUrl' })
}
Upvotes: 0
Reputation: 92274
You can just tell the fieldLabel to be a link 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
}
});
Upvotes: 1
Reputation: 654
Here is a solution of your problem: [hyperlink in Sencha EXT JS]: how to create hyper link in extjs4?
or you can add new event for your label:
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");
});
});
Upvotes: 1