Failed To Set Event Handler In Javascript
I want to add an event handler for input text controls. The controls is generated dynamically. My code is like: JavaScript: var settings_check = new Array('checkVMName()','checkDis
Solution 1:
You are creating an array of strings with function invocations in them, this is completely incorrect.
You need to assign references to the functions that you wish to be invoked when the event fires. You'd do this by simply storing the names of the functions (without the ()
or quotes) in your array, and it should work (the functions must be previously defined in the current scope as well):
var settings_check = [checkVMName, checkDiskMB, checkMemMB, checkEsx, checkDatastore];
So, in essence, settings_check
is simply an array of function references.
See this jsFiddle example illustrating this concept.
Post a Comment for "Failed To Set Event Handler In Javascript"