For some reason VueJS is now messing up my form submit, by erasing the post data from the Ajax serialize() function.
I think it may be because I am using Ajax and Jquery, but I'm not sure how to fix.
This code works fine when I'm not using VueJS
<script>
$(function(){
$('#save').click(function () {
$.ajax({type:'POST',
url: 'URL_HERE',
data:$('#form').serialize(), success: function(response) {
alert('saved!');
}});
return false;
});
});
</script>
However by adding my VUE code, it no longer submits form data
<script>
new Vue({
el: '#app',
data: {
bgColor: '#FFFFFF',
}
});
</script>
Parts of the HTML
<div id="app">
<form method="post" id="form" enctype="multipart/form-data" onSubmit="return false;">
<!-- various inputs and things in here -->
</form></div>
Any thoughts on why VueJS could be messing up my form submit? Or is it simply not compatible with Ajax / Jquery?
ANSWER: Looks like the answer is that I need the <div id="app"> inside of the <form> tag.
<form>. It could also be outside the<form>, as shown in this codepen