I want to test that certain actions occur when an action is clicked, I also want to leave all JavaScript out of my html, so I have attempted to bind my eventhandler using jquery so I end up with something like:
jQuery(function () {
jQuery('#myButton').bind('click', function (event) {
event.preventDefault();
doSomething();
});
});
Then set up a spy to watch the doSomething() method. The only problem is that it can't find the button with id
myButton.
If I set up a function to run the event handler binding and call it from my spec then everything works as expected.
I am running this using the standalone html spec runner and I believe that the functions if firing against the actual spec runner and not my fixture.
Is there a way of fixing this, any help would be appreciated.
Thanks
Tom