v0.10.0c - Fixed WashingMachine create & update AJAX
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
@csrf
|
||||
@method("put")
|
||||
<label for="name_first">Vaskemaskine Navn:</label>
|
||||
<label hidden id="error" for="errormesseages">Vaskemaskinen med den lokation findes allerede</label>
|
||||
<input type="text" name="name" id="name" max="60" value="{{$machine->name}}" required>
|
||||
<select class="w-100" name="location_id" id="location_id" class="mb-2" required>
|
||||
<option disabled> -- Vælg Lokation -- </option>
|
||||
@@ -25,7 +26,7 @@
|
||||
<option {{ $selected }} value="{{ $location->id }}">{{ $location->name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
<input type="submit" class="btn btn-dark text-white" value="Rediger">
|
||||
<input type="submit" id="disable" class="btn btn-dark text-white" value="Rediger">
|
||||
</form>
|
||||
@endsection
|
||||
@section("scripts")
|
||||
@@ -38,5 +39,82 @@
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
//Dont delete me, if the user reloads the pages with text in the text-box this code runs.
|
||||
$(document).ready(function () {
|
||||
$value = $('#name').val();
|
||||
$.ajax({
|
||||
type: 'get',
|
||||
url: '{{route('washing-machines.nameCheckUpdate')}}',
|
||||
data: {'nameCheck':$value, 'location': $('#location_id').val(), 'id': {{$machine->id}}},
|
||||
success:function (data) {
|
||||
console.log(data);
|
||||
if(data){
|
||||
$("#error").show(100);
|
||||
$("#error").css('color', 'red');
|
||||
$("#disable").prop('disabled', true);
|
||||
$('#disable').css('cursor','not-allowed');
|
||||
}else{
|
||||
$("#error").hide();
|
||||
$("#disable").prop('disabled', false);
|
||||
$('#disable').css('cursor','pointer');
|
||||
}
|
||||
|
||||
},
|
||||
error:function (data) {
|
||||
console.log(data);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#name').on('keyup', function () {
|
||||
$value = $(this).val();
|
||||
$.ajax({
|
||||
type: 'get',
|
||||
url: '{{route('washing-machines.nameCheckUpdate')}}',
|
||||
data: {'nameCheck':$value, 'location': $('#location_id').val(), 'id': {{$machine->id}}},
|
||||
success:function (data) {
|
||||
if(data){
|
||||
$("#error").show(100);
|
||||
$("#error").css('color', 'red');
|
||||
$("#disable").prop('disabled', true);
|
||||
$('#disable').css('cursor','not-allowed');
|
||||
}else{
|
||||
$("#error").hide();
|
||||
$("#disable").prop('disabled', false);
|
||||
$('#disable').css('cursor','pointer');
|
||||
}
|
||||
|
||||
},
|
||||
error:function (data) {
|
||||
console.log(data);
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
$('#location_id').on('change', function () {
|
||||
$value = $('#name').val();
|
||||
$.ajax({
|
||||
type: 'get',
|
||||
url: '{{route('washing-machines.nameCheckUpdate')}}',
|
||||
data: {'nameCheck':$value, 'location': $('#location_id').val(), 'id': {{$machine->id}}},
|
||||
success:function (data) {
|
||||
if(data){
|
||||
$("#error").show(100);
|
||||
$("#error").css('color', 'red');
|
||||
$("#disable").prop('disabled', true);
|
||||
$('#disable').css('cursor','not-allowed');
|
||||
}else{
|
||||
$("#error").hide();
|
||||
$("#disable").prop('disabled', false);
|
||||
$('#disable').css('cursor','pointer');
|
||||
}
|
||||
|
||||
},
|
||||
error:function (data) {
|
||||
console.log(data);
|
||||
}
|
||||
});
|
||||
})
|
||||
</script>
|
||||
@endsection
|
||||
|
||||
Reference in New Issue
Block a user