-
4 Nov 2011 2:17 PM #1
Answered: Ext.get("link").on('click', function() { ##need help
Answered: Ext.get("link").on('click', function() { ##need help
when i click more 1 time its open win more and more
iwant it to open just 1 time
tankou
Code:Ext.onReady(function() { Ext.get("link").on('click', function() { var win = new Ext.Window({ width:200,y:'20', x:'70', border:false, height: 450,closeAction: 'hide' }); win.show(); }); });
-
Best Answer Posted by mitchellsimoens
First, let's clean your original code up so we can all easily read it:
Now, if you want a listener to fire only once and remove itself, you can use the single listener config (changes in red):Code:Ext.onReady(function() { Ext.get('link').on('click', function() { var win = new Ext.Window({ width : 200, y : 20, x : 70, border : false, height : 450, closeAction : 'hide' }); win.show(); }); });
Problem is, when a Window is closed, that link is no longer going to fire the click event. The way to get around that is not to use the single config and since you are using closeAction as 'hide', just need to see if there is already a Window:Code:Ext.onReady(function() { Ext.get("link").on('click', function() { var win = new Ext.Window({ width : 200, y : 20, x : 70, border : false, height : 450, closeAction : 'hide' }); win.show(); }, null, { single : true }); });
Code:Ext.onReady(function() { var win; Ext.get('link').on('click', function() { if (!win) { //if there is no Window, create one! win = new Ext.Window({ width : 200, y : 20, x : 70, border : false, height : 450, closeAction : 'hide' }); } win.show(); }); });
-
4 Nov 2011 5:06 PM #2
When you say open one time...
Do you mean that you want the window to open only when the user clicks the element the first time?
Or do you mean that you only want the window to show if it isn't already showing?
-
5 Nov 2011 12:58 AM #3
if i click on the link 5 time ,to close it i need 5 time to click on close its open 5 window
i want just 1 window to show
tankyou
-
5 Nov 2011 1:11 AM #4
Approximately soPHP Code:Ext.onReady(function() { Ext.get("link").on('click', function() { var win = new Ext.Window({ width:200,y:'20', x:'720', border:false, height: 450,closeAction: 'hide',
listeners: {
hide: function() {
Ext.get("link").un('click');
}
}
}); win.show(); });
-
5 Nov 2011 1:29 AM #5
-
5 Nov 2011 1:38 AM #6
i want like this
i i click 10 times its open 1 win not 10 window
tankyou
Code:Ext.onReady(function(){ var win; var button = Ext.get('show-btn'); button.on('click', function(){ // create the window on the first click and reuse on subsequent clicks if(!win){ win = new Ext.Window({ layout : 'fit', width : 500, height : 300, closeAction :'hide', plain : true });} win.show( button); }); });
-
5 Nov 2011 6:29 AM #7Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,599
- Vote Rating
- 434
- Answers
- 3102
First, let's clean your original code up so we can all easily read it:
Now, if you want a listener to fire only once and remove itself, you can use the single listener config (changes in red):Code:Ext.onReady(function() { Ext.get('link').on('click', function() { var win = new Ext.Window({ width : 200, y : 20, x : 70, border : false, height : 450, closeAction : 'hide' }); win.show(); }); });
Problem is, when a Window is closed, that link is no longer going to fire the click event. The way to get around that is not to use the single config and since you are using closeAction as 'hide', just need to see if there is already a Window:Code:Ext.onReady(function() { Ext.get("link").on('click', function() { var win = new Ext.Window({ width : 200, y : 20, x : 70, border : false, height : 450, closeAction : 'hide' }); win.show(); }, null, { single : true }); });
Code:Ext.onReady(function() { var win; Ext.get('link').on('click', function() { if (!win) { //if there is no Window, create one! win = new Ext.Window({ width : 200, y : 20, x : 70, border : false, height : 450, closeAction : 'hide' }); } win.show(); }); });Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.


my ext js site
Reply With Quote