This is my simple form:
<form accept-charset="utf-8" class="form-vertical" id="template" autocomplete="off" name="template" method="POST" action="http://test.dev/templates">
...various inputs and HTML here...
<input class="btn btn-primary" type="submit" value="Update">
</form>
This is my JS which doesn't prevent the form from submitting:
<script type="text/javascript">
(function ($) {
'use strict';
$("form#template").on('submit.template', function (e) {
e.preventDefault();
console.debug(e.relatedTarget);
return false;
});
}(jQuery));
</script>
From past experience, this should prevent the form from submitting when Update
is clicked. Feel like I am missing something painfully obvious. What could be going on here?
jQuery 2.1.1