v0.10.0b - Fixed Location update AJAX

Added - You are now able to delete a location
This commit is contained in:
Anders
2020-08-17 10:43:52 +02:00
parent 773655c294
commit 3bde377caa
4 changed files with 68 additions and 9 deletions
@@ -15,8 +15,9 @@
@csrf
@method("put")
<label for="name">Lokationsnavn:</label>
<label hidden id="error" for="errormesseages">Lokation findes allerede</label>
<input type="text" name="name" id="name" value="{{ $location->name }}" required>
<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")
@@ -29,5 +30,57 @@
}
);
});
//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('locations.nameCheckUpdate')}}',
data: {'nameCheck':$value, 'id':{{$location->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('locations.nameCheckUpdate')}}',
data: {'nameCheck':$value, 'id':{{$location->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