Live search

This commit is contained in:
2020-07-07 19:29:21 +02:00
parent 4e69768ae8
commit 9c17623518
6 changed files with 69 additions and 26 deletions
@@ -10,8 +10,16 @@
@endsection
@section("content")
<script src="http://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
<div class="row align-items-center">
<a class="btn btn-inline btn-sde-blue mb-0" href="{{ route('contacts.create') }}"><img src="{{ asset('/images/icons/plus.svg') }}" alt="Create">Opret Kontakt</a>
<form method="post" action="{{ route("users.store") }}">
@csrf
<input type="text" class="form-controller" id="search" name="search" placeholder="Søg på navn,email,telefon"></input>
</form>
</div>
<table class="tbl mt-2">
<tr>
@@ -39,4 +47,23 @@
</tr>
@endforeach
</table>
<script>
$('#search').on('keyup', function () {
//alert('Test');
$value = $(this).val();
$.ajax({
type: 'get',
url: '{{URL::to('contacts')}}',
data: {'search':$value},
success:function (data) {
$('tbody').html(data);
console.log(data);
}
});
})
</script>
@endsection
@@ -10,19 +10,11 @@
@endsection
@section("content")
<div class="row align-items-center">
<div class="row align-items-center">
<a class="btn btn-inline btn-sde-blue mb-0" href="{{ route('users.create') }}"><img src="{{ asset('/images/icons/plus.svg') }}" alt="Create">Opret Bruger</a>
<form method="post" action="{{ route("users.store") }}">
@csrf
<input type="text" class="form-controller" id="search" name="search"></input>
<input type="submit" class="btn btn-dark text-white" value="Søg">
</form>
</div>
<table class="tbl mt-2">
<tr>
@@ -41,6 +33,7 @@
<td>{{ $user->email }}</td>
<td>{{ $user->phone }}</td>
<td>
@for($i = 0; $i < count($user->roles); $i++)
@if(count($user->roles)-1 != $i)
{{$user->roles[$i]->name}},
@@ -60,6 +53,5 @@
</tr>
@endforeach
</table>
{{ $users->links() }}
@endsection