When i click to the button, it fire to ajax call and send button's id with request. Everthing works except my predefined button id does not come with request. It comes with value 'ext6-gen'. Do anyone know what i suppose to do for getting my predefined id.
//i defined a container with a textfield and button
var c2 = Ext.extend(Ext.Container, {
id : c2, initComponent : function() {
this.items = [ {
xtype : 'textfield', id : 'c3'}
, {
xtype : 'button', id : 'c4'} //it has id!!!
], c2.superclass.initComponent.call(this); }
}
);
Ext.onReady(function() {
var HttpReq = function(e, t) {
v开发者_如何学Car elm = Ext.get(e.target);
Ext.Ajax.request( {
loadMask : true,
url : 'Default.sample',
params : {id : elm.id},
success : function(resp) {alert(resp.responseText); }
});
};
Ext.get('c4').on('click', HttpReq); //i assign click event to button
});
i found something. ext button element wraps html input element with a table. That html element has different id than ext button element.
But still dont know how to get ext button element on event call.
Thank you.
Instead of
params : {id : elm.id},
try
params : {id : e.id},
Finally i found!
i know it is silly, but it took a day to find it :(.
i just change e.id to this.id then it sends wrapper ext element's id.
Ext.onReady(function() {
var HttpReq = function(e, t) {
//var elm = Ext.get(e.getTarget());
//var targetEl = Ext.fly(elm.id);
//alert(this.id);
//elm.highlight();
Ext.Ajax.request( {
loadMask : true, url : 'Default.sample', params : {
id : this.id}
, success : function(resp) {
alert(resp.responseText); }
}
); };
done.
精彩评论