-
Notifications
You must be signed in to change notification settings - Fork 61
/
ajax.blade.php
95 lines (89 loc) · 3.11 KB
/
ajax.blade.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
@push('js')
<script type="text/javascript">
$(document).ready(function(){
@if($typeForm == 'create')
var selectID = '{{ $selectID }}';
$(document).on('change','#'+selectID,function(){
var selectIDValue = $('#'+selectID+' option:selected').val();
if(selectIDValue > 0){
$.ajax({
url:'{{ $url }}',
dataType:'html',
type:'post',
data:{_token:'{{ csrf_token() }}','{{ $selectID }}':selectIDValue},
beforeSend: function(){
$('.{{ $outputClass }}').html('<center><i class="fa fa-spinner fa-spin"></i></center>');
},success: function(data){
$('.{{ $outputClass }}').html(data);
$('#{{ $outputClass }}').select2();
}
});
}else{
$('.{{ $outputClass }}').html('<select class="form-control" id="{{ $outputClass }}"></select>');
$('#{{ $outputClass }}').select2();
}
});
$('.{{ $outputClass }}').html('<select class="form-control" id="{{ $outputClass }}"></select>');
$('#{{ $outputClass }}').select2();
@if(old($outputClass))
var selectIDValue = $('#'+selectID+' option:selected').val();
$.ajax({
url:'{{ $url }}',
dataType:'html',
type:'post',
data:{_token:'{{ csrf_token() }}','{{ $selectID }}':selectIDValue,select:'{{ old($outputClass) }}'},
beforeSend: function(){
$('.{{ $outputClass }}').html('<center><i class="fa fa-spinner fa-spin"></i></center>');
},success: function(data){
$('.{{ $outputClass }}').html(data);
$('#{{ $outputClass }}').select2();
}
});
@endif
@elseif($typeForm == 'edit')
var selectID = '{{ $selectID }}';
$(document).on('change','#'+selectID,function(){
var selectIDValue = $('#'+selectID+' option:selected').val();
if(selectIDValue > 0){
$.ajax({
url:'{{ $url }}',
dataType:'html',
type:'post',
data:{_token:'{{ csrf_token() }}','{{ $selectID }}':selectIDValue},
beforeSend: function(){
$('.{{ $outputClass }}').html('<center><i class="fa fa-spinner fa-spin"></i></center>');
},success: function(data){
$('.{{ $outputClass }}').html(data);
$('#{{ $outputClass }}').select2();
}
});
}else{
$('.{{ $outputClass }}').html('<select class="form-control" id="{{ $outputClass }}"></select>');
$('#{{ $outputClass }}').select2();
}
});
$('.{{ $outputClass }}').html('<select class="form-control select2" id="{{ $outputClass }}"></select>');
$('#{{ $outputClass }}').select2();
@if($selectedvalue > 0)
var selectIDValue = $('#'+selectID+' option:selected').val();
$.ajax({
url:'{{ $url }}',
dataType:'html',
type:'post',
data:{
_token:'{{ csrf_token() }}',
'{{ $selectID }}': '{{ $parentValue }}',
select:'{{ $selectedvalue }}'
},
beforeSend: function(){
$('.{{ $outputClass }}').html('<center><i class="fa fa-spinner fa-spin"></i></center>');
},success: function(data){
$('.{{ $outputClass }}').html(data);
$('#{{ $outputClass }}').select2();
}
});
@endif
@endif
});
</script>
@endpush