Switched to using event delagtion, fixes issue with stopping propagation in the click event of a button.