Как правильно настроить HTML-код для замены кнопки подтверждения в Sweet Alert 2? - PullRequest
0 голосов
/ 20 июня 2019

В настоящее время я нахожусь на важном этапе моей программы Sweet Alert.Мне нужно заменить кнопки отправки и отмены по умолчанию некоторыми внутренними кнопками HTML (форма обрабатывается с помощью ajax), но я не могу найти никаких ссылок на то, как правильно получить отправленную информацию или закрыть предупреждение.

HTML-код моей формы:

<div class="card">
    <div class="card-header card-header-icon" data-background-color="orange">
        <i class="large material-icons">cloud_upload</i>
    </div>
    <br>
    <div class="card-content">
        <form {% if modal_title_id %} id="{{ modal_title_id }}"{% endif %}
              class="form-{{ style|default:'stacked' }} {{ class }} create-form"
              method="{{ method|default:'post' }}"
              {% if action %} action="{{ action }}"{% endif %}
              enctype="multipart/form-data">
            {% if not method == "get" %}{% csrf_token %}{% endif %}
            {% if title %}<h5><i class="icon-sitemap icon-large"></i>{{ title }}</h5>{% endif %}
            {% include 'dashboard/partials/form_fields.html' %}
        </form>
        <div class="row">
            <button type="button" class="btn btn-secondary" id="closeSwal">{% trans 'Close' %}</button>
            <button type="submit" class="btn btn-primary" id="PostSwal">{% trans 'Upload File' %}</button>
        </div>
    </div>
</div>

HTML-код моей кнопки:

<p>
    <button type="button"
            class="btn btn-primary upload-file-js"
            data-url="{% url 'crm:customer:lead_upload' %}">
        <span class="glyphicon glyphicon-plus"></span>
        Importar Leads
    </button>
    <button type="button" class="btn btn-primary js-import-client">
        <span class="glyphicon glyphicon-plus"></span>
        Importar Clientes
    </button>
</p>

и мой js-код:

$('.upload-file-js').click(function() {
    var uploadUrl = $(this).attr('data-url')

    $.ajax({
        url: uploadUrl,
        type: 'get',
        dataType: 'json',
        success: function (data) {
            Swal.fire({
                title: '<strong>Importar Arquivo</strong>',
                html: data.html_template,
                showCancelButton: false,
                showConfirmButton: false,
                allowOutsideClick: true,
                });
        }
    });

});

Любая помощь будет принята с благодарностью.

...