-
28 Oct 2012 10:25 AM #1
Ext Js Button
Ext Js Button
Hi,
I'm using Extjs button for save operation,
new Ext.Button({
text: 'Save',
id:'save_id',
width:'108px',
height: '25px',
renderTo: 'save_button',
listeners: {
click: function(){ save(); }
}});
I'm calling this method by F9 (functional key on keyboard) and
also by on click with mouse.
By F9:
document.onkeyup = function (e) {
var unicode=e.keyCode? e.keyCode : e.charCode;
if(unicode==120){
Ext.getCmp('save_id').fireEvent("click", this);
}
}
while simultaneously access using keyboard and mouse , save function called for two times
but my requirement is , the function should called once even though accessed by keyboard and mouse.
Please guide me to resolve this parallel issue.
-
30 Oct 2012 2:17 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,684
- Vote Rating
- 435
First, I wouldn't fire the click event. I would use the handler config on the button and then execute the handler method on the button.
So you only want to fire save once per x amount of time or while an action is taken?
If while an action is taken I would set a variable or property to say that the action is pending and when the action is finished change that var/prop so that the save method will continue to fire (of course the save method should check the var/prop to allow it to continue to execute).
If after x amount of time, same as above only set the var/prop as a date object and then check the difference between that var/prop with the current time and if the difference is more than your x amount of time then allow the save method to continue to execute.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.
-
30 Oct 2012 2:45 AM #3
Ext js button
Ext js button
Hi Dude,
Can you give some examples about this parallel issue, It is possible without time factor.
-
30 Oct 2012 3:00 AM #4
This is just basic JS logic.
Set a global/namespaced variable:
Then when you call the save function:Code:var currentlySaving;
Then in your save function:Code:if(currentlySaving != true) { save() }
Code:currentlySaving = true; // Save logic here currentlySaving = false;
-
30 Oct 2012 3:24 AM #5
Ext js button
Ext js button
Thanks a lot... willigogs and mitchellsimoens
-
30 Oct 2012 5:11 AM #6Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,684
- Vote Rating
- 435
I wouldn't do a global variable. Functions are really objects and can have properties (watch out for memory leaks tho)
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.


Reply With Quote