I have a form with a name field and a select
for provinces . The point is that I enter a name, and when I select a province, I delete what I wrote in the name. And searching and testing I get to give that if I delete the v-model
of select
, that does not delete the name, but I need the v-model
in select
.
Name:
<label for="first_name">Nombre</label>
<input type="text" id="first_name" name="first_name" value="{{old('first_name')}}" class="form-control" placeholder="-" autocomplete="off" maxlength="255"/>
Province:
<label for="province">Provincia</label>
<select name="province" id="province" class="form-control" v-model="province" v-on:change="getDistricts(province)">
<option value="" hidden>-- Seleccionar --</option>
@foreach($provinces as $province)
<option value="{{$province->code}}" {{ (Input::old('province') == $province->code ? "selected" : "") }}> {{$province->province}}</option>
@endforeach
</select>
and I have vue defined as:
var vm = new Vue({
el: '#finaldraw',
data: {
province: '1',
m_district: '',
districts: [],
places: []
},
delimiters: ['<%', '%>']
});
vm.getDistricts = function (province) {
$.ajax({
url: '/geoDistricts/getDistricts',
method: 'POST',
dataType: 'json',
data: {province: province},
beforeSend: function () {
$(".spinner-select i.province").css('display', 'inline-block');
$("#district").prop('disabled', true);
$("#place").prop('disabled', true);
},
complete: function () {
$(".spinner-select i.province").css('display', 'none');
},
success: function (data) {
$("#district").prop('disabled', false);
// vm.districts = data;
}
});
};