Ekapp/skolehjem/resources/views/admin/guides-category/edit.blade.php

86 lines
3.1 KiB
PHP

@extends("admin.layout.base")
@extends("admin.layout.header")
@section("title")
Kategori - Rediger
@endsection
@section("path")
<a href="{{route('guides-category.edit', $guideCategory )}}" class="text-white">Rediger kategori</a> /
@endsection
@section("content")
<h1>Rediger vejlednings kategori</h1>
<form method="post" action="{{ route("guides-category.update", $guideCategory) }}">
@csrf
@method("put")
<label for="name">Kategori navn:</label>
<label hidden id="error" for="errormesseages">Kategorien findes allerede</label>
<input type="text" name="guidesCategoryName" id="guidesCategoryName" value="{{ $guideCategory->guidesCategoryName }}" required>
<input type="submit" id="disable" class="btn btn-dark text-white" value="Rediger">
</form>
@endsection
@section("scripts")
<script>
$(function() {
$('form').areYouSure(
{
message: 'It looks like you have been editing something. '
+ 'If you leave before saving, your changes will be lost.'
}
);
});
//Dont delete me, if the user reloads the pages with text in the text-box this code runs.
$(document).ready(function () {
$value = $('#guidesCategoryName').val();
$.ajax({
type: 'get',
url: '{{route('guides-category.nameCheckUpdate')}}',
data: {'nameCheck':$value, 'id':{{$guideCategory->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);
}
});
});
$('#guidesCategoryName').on('keyup', function () {
$value = $(this).val();
$.ajax({
type: 'get',
url: '{{route('guides-category.nameCheckUpdate')}}',
data: {'nameCheck':$value, 'id':{{$guideCategory->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