Add preview from father, add new features
This commit is contained in:
34
resources/views/load/form/toggle.blade.php
Normal file
34
resources/views/load/form/toggle.blade.php
Normal file
@@ -0,0 +1,34 @@
|
||||
@if(!defined('LOAD_TOGGLE'))
|
||||
@push('scripts')
|
||||
<script src="{{ asset('/assets/plugins/bootstrap4-toggle/js/bootstrap4-toggle.min.js') }}"></script>
|
||||
|
||||
<script>
|
||||
function initToggle(url, sel, data, callback) {
|
||||
var selector = (typeof(sel) == 'undefined') ? '.toggle' : sel;
|
||||
if (typeof(data) == 'undefined') {
|
||||
var data = {};
|
||||
}
|
||||
$(selector).bootstrapToggle();
|
||||
|
||||
$('input' + selector).change(function() {
|
||||
console.log($(this));
|
||||
data['id'] = $(this).data('id');
|
||||
data['active'] = $(this).is(':checked');
|
||||
if (data['id'] && (typeof(url) != 'undefined') && (url != '')) {
|
||||
var dataJson = Object.assign({}, data);
|
||||
$.post(url, dataJson);
|
||||
}
|
||||
if (typeof(callback) != 'undefined') {
|
||||
eval(callback);
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
@endpush
|
||||
|
||||
@push('css')
|
||||
<link rel="stylesheet" href="{{ asset('/assets/plugins/bootstrap4-toggle/css/bootstrap4-toggle.min.css') }}">
|
||||
@endpush
|
||||
@php(define('LOAD_TOGGLE', true))
|
||||
@endif
|
||||
Reference in New Issue
Block a user