PDA

View Full Version : Existing HTML and MVC



fliptight
30 Sep 2011, 1:32 PM
MVC works great for getting the controller to listen to Ext JS components from the view and all, but say you have existing HTML like so:



<body>
<div id="container">
<a href="#" id="testLink">Some Test Link</a>
</div>
</body>


how do you get the controller to listen to a click event from a normal link in the view without doing something hacky (imo) such at this?

View


...
initComponent: function () {
this.addEvents('testLinkClicked');


Ext.get('testLink').on('click', function() {
this.fireEvent('testLinkClicked');
}, this);


this.callParent();
}
...


Controller


init: function () {
this.control({
'test': {
'testLinkClicked': function() {
console.log('clicked link');
}
}
});
}