fire7side Posted October 14, 2015 Share Posted October 14, 2015 I'm having trouble, perhaps it's with my understanding of javascript, but when I use the .load(functionName) it works. But how do I add perameters? If I add parenthesis to the function name, it quits working. Is it just that you can't add parameters or is it some js convention? I came across the same thing with requestAnimationFrame(). If I add parameters, I get all sorts of problems. Quote Link to comment Share on other sites More sharing options...
chg Posted October 14, 2015 Share Posted October 14, 2015 I'm having trouble, perhaps it's with my understanding of javascript, but when I use the .load(functionName) it works. But how do I add perameters? If I add parenthesis to the function name, it quits working.If you write functionName() as the argument to load then JavaScript calls the function (immediately upon executing the line) and supplies whatever is returned by functionName() as the argument to load().Is it just that you can't add parameters or is it some js convention? I came across the same thing with requestAnimationFrame(). If I add parameters, I get all sorts of problems.You probably want to use bind() [ https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_objects/Function/bind ] or create an anonymous function with the arguments and call to your actual function baked in eg. .load( function() { functionName("foo"); } ); Quote Link to comment Share on other sites More sharing options...
fire7side Posted October 14, 2015 Author Share Posted October 14, 2015 OK, thanks. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.