I've got a few buttons with the class PhotoUploadSubmit
, and when a button is clicked, a custom click handler is used to look at sibling elements, etc. The click handler doesn't work, debugger
never goes off, breakpoints are not hit, and I'm totally baffled.
<div class="formDataContext">
<input type="file" name="ImageData" style="display:none" />
<button class="PhotoUploadSubmit"><i class="fa fa-camera fa-5x"></i></button>
</div>
<script type="text/javascript">
$(function () {
$(".PhotoUploadSubmit").on("click", function () {
debugger;
var currentFormDataContext = $(this).closest(".formDataContext");
console.log(currentFormDataContext);
var FileInput = currentFormDataContext.find("input:file")[0];
console.log(FileInput);
$(FileInput).click();
});
$("input:file").change(function () {
var currentFormDataContext = $(this).closest(".formDataContext");
uploadImage(currentFormDataContext);
});
});
</script>
In terms of what I've tried, I've tried putting the click handler outside of document.ready
, I've tried using the debugger;
keyword, and I've tried setting breakpoints. There's no console errors.