jquery live automatically incrementing keyup event -
I'm really confused, and it's also not sure what to look for in finding answers. I'm getting many calls for the javascript function I'm not able to understand.
What does this code do
$ ('expenses_txt'). Live (\ 'keyup \', function () {$ (this) .typeWatch ({Highlight: true, wait: 500, capture lendement: 0, callback: Calculate_expenses});});
"calculate_expenses" is a JavaScript function that uses jquery ajax to call a php page which gives data appearing in a span.
I'm using firebug to help me debug and in the Calculate_expenses function, when I'm calling this function, I've put "console.log" to debug it.
This is happening when this happens, so I have only 1 input box, when I press only one key, puts the output given in the console as a debug msg, as it should, When I press an input again in the same input box the console is doubled (i.e., the calculate_expenses function was called twice, but it should be called only once), when I press a key again (total 3 Key press) Output in the console The calculate_expenses function now ..... and even further. I do not really know what is happening here in the code that I see that it will call only the CalText Expense function at 1 time, but when the firebug is used, it is actually being called and called. When i do not want it
Any thoughts? Am I using it () If I use the "key usage" event it works fine, to type the problem I need to use the plug-in typingweb plug-ins, until the typing process ends and the trigger also triggers the event. Get ready soon The reason I am using Live () is because I add element to DOM dynamically and this is the only way, I could understand how to use both types and dynamically add those components to the dome Required for ...
Your thoughts are appreciated Thanks.
Where is $ ('expenses_txt'). Live ()
kept the piece? It seems that it is being triggered multiple times
Set a breakpoint (click on the firebug script tab, margin on the left margin of the line number) on $ ('expenses_txt'). Live ()
line should trigger it only once. If it triggers multiple times, you will easily see a stack trace (which you should take back to the culprit).
Also, set a breakpoint (where you use Typewitch) during closing. The type watch part can be offender because it is reinstating every keyboard (whether it is already "treated" (and sometimes callback bound) this
.
jQuery ('# Check it using jQuery (' # element '): )
To see the plugin docs, the authors are responsible for someone like this.
Comments
Post a Comment