I'm new on ExtJS and still learning how things are working there.. In my case I have an html page which I load through ajax in my index page and inside this html there is a form element. So far I have managed to set an event listener to the button of my form so when I'm clicking the button the event is working perfect. What I'm not sure is how to pass the form's field values from processing them in my controller.
here is the example code:
The form:
<form id="loginform">
<fieldset>
<input type="text" id="usn" placeholder="User" /><br />
<input type="password" id="pwd" placeholder="Password"/>
</fieldset>
<p><input type="button" id="lg" value="Enter" /></p>
</form>
My View:
Ext.define('App.view.Login', {
extend: 'Ext.container.Container',
alias: 'widget.login',
renderTo: 'wrap',
initComponent: function() {
this.items = [{
loader: {
autoLoad: true,
url: "web/login.html",
renderer: function(loader, response, active) {
var res = response.responseText;
loader.getTarget().update(res);
}
}
}];
this.addEvents('loginUser');
this.callParent(arguments);
},
afterRender: function() {
this.mon(this.el, 'click', this.onUserClick, this, {
delegate: '#lg'
});
this.callParent(arguments);
},
onUserClick: function(ev, t) {
ev.stopEvent();
var params = Ext.fly(t).getAttribute('value');
this.fireEvent('loginUser', params, this, ev);
}
});
The cotroller:
Ext.define('App.controller.Login', {
extend: 'Ext.app.Controller',
views: [ 'Login' ],
refs: [{
selector: 'login',
ref: 'login'
}],
init: function() {
this.control({
'login':{
loginUser: this.onLoginAuth
}
});
},
onLoginAuth: function(params, component, event){
Ext.widget('users');
this.getLogin().destroy();
}
});
Does someone has any idea how can we implement it?