i want know how call function string value
in other questions found this: window["functionname"](arguments);
, , assume not working cause functions not global, , don't want them global.
i have example here:
(function ( $ ) { "use strict"; var testing, showme; testing = function(){ alert('working'); }; showme = function(test){ window[test](arguments); } $(document).ready(function(){ showme('testing'); }); })(jquery);
as can see, want call function, testing()
using string value.
window
object. can place inside arbitrary object:
(function ( $ ) { "use strict"; var testing, showme, funcs = {}; funcs.testing = function(){ alert('working'); }; showme = function(test){ funcs[test](arguments); } $(document).ready(function(){ showme('testing'); }); })(jquery);
Comments
Post a Comment