{{ Form::open(['route' => 'Admin.Core.Mail.MailTemplate.storeAjax', 'id' => 'preview_template-form', 'autocomplete' => 'off', 'files' => true]) }}

	<input type="hidden" name="id" id="template_id" value="{{ $id ?? null }}">

    <div class="row mb-3">
        <div class="col-6">
            @include('components.form.select', [
                'id_name' => 'model_id',
                'name' => 'model_id',
                'list' => $list,
                'class' => 'select2',
                'with_empty' => '',
                'label' => __('Core.users.name'),
            ])
        </div>
    </div>

    <x-card title="Preview">
        <div id="previewTemplate"></div>
    </x-card>

{{  Form::close() }}

<script>
    initSelect2();
    $('#model_id').change(function() {
        var model_id = $(this).find(":selected").val();
        var template_id = $('#template_id').val();
        var url = "{{ route('Admin.Core.Mail.MailTemplate.preview') }}/" + template_id + '/' + model_id;
        $.get(url, function(data) {
            $('#previewTemplate').html(data);
        });
    })
</script>
