PDA

View Full Version : open window with animateTarget does not work



lee el
5 Jan 2013, 2:46 AM
Hi,

I am trying to show a window with the show method with the property animateTarget in order to see the window open with animation from a simple button when this button is clicked.
the problem is that there is no animation and the console shows this error:
Uncaught TypeError: Cannot call method 'getBox' of null

when I try to open a messageBox when this button is clicked with animateTarget this works well and the messagebox is animated from the button
what is the different between them? according to the API the window is also capable to be open with animation.

window code:


text: 'windowButton',
handler: function() {


var win = Ext.create('Ext.window.Window', {
title: 'Hello',
height: 200,
width: 400,
});
win.show({
animateTarget:this
});
}





MessageBox code (animation works well):


text: 'windowButton',
handler: function() {
var msgBox = Ext.create('Ext.window.MessageBox', {
});
msgBox.show({
title: 'test',
msg: 'Please enter your address:',
width: 300,
buttons: Ext.Msg.OKCANCEL,
animateTarget:this
});



}





thanks for your help,
Lee

mitchellsimoens
7 Jan 2013, 10:50 AM
It's expecting an element not a component.

slemmon
7 Jan 2013, 10:58 AM
Try doing animateTarget: this.id
*or this.el

lee el
7 Jan 2013, 12:07 PM
Hi,

with both options the result is the same (error message in the log)

slemmon
7 Jan 2013, 12:14 PM
Oh, I just realized you were passing a config to show(). While that won't apply the config to the window you can set the animateTarget before you do show().



Ext.widget('button', {
renderTo: Ext.getBody()
, text: 'Open Window'
, handler: function (btn) {
var win = Ext.create('Ext.window.Window', {
title: 'Hello',
height: 200,
width: 400,
});
win.animateTarget = btn.id;
win.show();
}
});

lee el
7 Jan 2013, 12:19 PM
Thanks ! this is working now ...

thank you
Lee