Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialReuben Rail
3,338 PointsWhy do the named functions fire without parenthesis "()" and fail with parenthesis?
Why does the following code work without parenthesis after the function names.....
$password.focus(passwordEvent).keyup(passwordEvent).keyup(confirmPasswordEvent).keyup(enableSubmitEvent);
$confirmPassword.focus(confirmPasswordEvent).keyup(confirmPasswordEvent).keyup(enableSubmitEvent);
enableSubmitEvent();
.......but this code does not.......
$password.focus(passwordEvent()).keyup(passwordEvent()).keyup(confirmPasswordEvent()).keyup(enableSubmitEvent());
$confirmPassword.focus(confirmPasswordEvent()).keyup(confirmPasswordEvent()).keyup(enableSubmitEvent());
enableSubmitEvent();
1 Answer
James Bradd
4,597 PointsFor that, you are not calling the function, you are just telling it what function will be the handler for that event type. You are telling jquery which function to call, not calling it yourself.
Jimmy Palelil
9,565 PointsJimmy Palelil
9,565 PointsAnd you dont even need to call enableSubmitEvent() at the end of the code. I dont know why that was not rectified in the end. Confused the hell out of me until i tired it myself.