-
26 Feb 2011 6:24 AM #1
[CLOSED]Strange behaviour: Window, closeAction and ComponentQuery
[CLOSED]Strange behaviour: Window, closeAction and ComponentQuery
I´m using a Window as modal dialog:
In initComponent I set a click handler for the toolbar button btnAddUsersPHP Code:Ext.define('SO.ux.client.UserAddUi', {
extend: 'Ext.Window',
title: 'Benutzer hinzufügen',
width: 600,
height: 300,
minHeight: 300,
layout: 'border',
modal: true,
id: 'userAddWindow',
dockedItems: [{
xtype: 'toolbar',
dock: 'top',
items: [{
xtype: 'button',
text: 'Hinzufügen',
icon: '../images/icons/user--plus.png',
id: 'btnAddUsers'
}]
}],
items: [
{
...
}
]
}
This works the first time the user opens the window. From the second time on this.down returns null and thus the window is not opened.PHP Code:,initComponent: function() {
SO.ux.client.UserAdd.superclass.initComponent.call(this);
this.down('#btnAddUsers').on('click', this.addUsersHandler, this);
}
-
26 Feb 2011 7:26 AM #2
this is not directly related to your problem, but you should really use itemId instead of id (and then parent.getComponent(itemId)). Otherwise you indirectly create a singleton, since each further instance would get the same dom-id.
also prefer iconCls over icon.
best regards
tobiu
-
26 Feb 2011 8:04 AM #3
It is to do with duplicate ids if the closeAction of that Window is not 'hide'.
That Window should be closeAction: 'hide', and only created once.Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
26 Feb 2011 8:23 AM #4
O.k. I´ve refactored from id to itemId. Thank you for the hint I wasn´t aware of that.
But I don´t really understand that I have to use closeAction = 'hide'. The dialog is used very seldom and so I would like to destroy the window to save resources after it has been closed by the user. If I do this with all my widgets the user will run out of memory at some point.
-
26 Feb 2011 5:20 PM #5
Don't put non primitives in the object prototype (arrays, objects). This means they get shared across all instances.
Put them inside initComponent.Evan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
-
27 Feb 2011 1:08 AM #6
??? don´t understand your last reply evant.
This may be caused in my bad javascript know how. Can you explain in some words what I´m doing wrong and what I should do instead?
Sorry for those basic question.
-
27 Feb 2011 3:26 AM #7
maybe saki's example helps in this case:
http://blog.extjs.eu/patterns/file-p...-file-pattern/
look how he uses the initComponent-method.
or get jay's book -> ext js in action.
since there are no real classes in javascript, we are dealing with prototypes all the time. if you define a prototype, you can only add primitive datatypes (numbers, strings, booleans), but no arrays / objects as evan told you already. if you do so, every time you create a new instance with the new operator, it will get the identical array / object and this can get really bad if you are not dealing with singletons.
best regards
tobiu
Thank you for reporting this bug. We will make it our priority to review this report.
Similar Threads
-
[CLOSED][3.2.1] closeAction:'close' does not destroy window object
By squ3lch in forum Ext 3.x: BugsReplies: 1Last Post: 17 Jun 2010, 4:09 PM -
[CLOSED] Strange behaviour on Combo and Grid
By erikhedb in forum Ext GWT: Bugs (2.x)Replies: 3Last Post: 5 Oct 2009, 1:37 AM -
[CLOSED][3.x] Window.close() improvement to handle closeAction
By prometheus in forum Ext 3.x: BugsReplies: 4Last Post: 16 Jun 2009, 6:11 AM -
Strange behaviour with Ext.Window
By DoS in forum Ext 2.x: Help & DiscussionReplies: 2Last Post: 19 Mar 2009, 11:32 AM


Reply With Quote