Just like the title says, I'm trying to update a textarea based off multiple inputs. I have that part working (with line-breaks) using jQuery, however when I try to get the value of that textarea and display it elsewhere using vue.js, it doesn't work. Even weirder, when I edit the vue.js data-bound fields, it erases the textarea until the inputs are re-edited. I'm new to vue.js so I'm a little confused as to what's happening here. Any help is appreciated.
Here's a Fiddle with the same code as below:
$(document).ready(function() {
$(document).on('change keyup', 'input.url-field', function() {
var inputs = $('input.url-field');
var textareaVal = '';
for (var i = 0; i < inputs.length; i++) {
textareaVal += $(inputs[i]).val() + "\r\n";
}
$('textarea#urls').val(textareaVal);
});
// vue.js app
new Vue({
el: '#all',
data: {
phone: '',
urls: ''
}
});
});
input, textarea{
margin-bottom: 20px;
display: block;
}
<script src="https://vuejs.org/js/vue.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="all">
<form>
<label>Phone:</label>
<input name="phone" v-model="phone" type="text">
<label>URL1:</label>
<input class="url-field" name="url1" type="text">
<label>URL2:</label>
<input class="url-field" name="url2" type="text">
<textarea id="urls" name="urls" v-model="urls" cols="50" rows="5"></textarea>
</form>
<br>
<table>
<tr>
<td><strong>Phone:</strong></td>
<td>{{ phone }}</td>
</tr>
<tr>
<td><strong>URLs:</strong></td>
<td>{{ urls }}</td>
</tr>
</table>
</div>