I am working in Extjs4, and getting stuck on how to catch an event on hyperlink. I worked on it but couldn't get it solved.
Here is my code:
View code
Ext.define('AM.view.user.linkView', {
extend: 'Ext.panel.Panel',
alias: 'widget.Link',
title: 'My Cool Panel',
html: '<div><a href="#" id="linkId">This link will open a window</a></div><br /> <label for="myInput">Type here: </label><input name="myInput" type="text" value="" />',
});
Controller code
Ext.define('AM.controller.Users', {
extend: 'Ext.app.Controller',
stores: ['Users'],
models: ['User','Book'],
views: ['user.Edit', 'user.List','user.Create','user.linkView'],
init: function() {
this.control({
'Link': {
afterrender: function(cmp)
{
Ext.get('#linkId').on('click', function(event, target) {
console.log(target);
}, this);
}
}
});
}
});
When I run the code above I get this error:
Uncaught TypeError: Cannot call method 'on' of null
How can I solve this problem?