Загрузите функцию после того, как пользователь закрыл модальный - PullRequest
0 голосов
/ 24 апреля 2019

Я использую библиотеку под названием SweetAlert.Я хочу загрузить функцию после того, как пользователь закрыл модальное.

Мой код в настоящее время:

Swal.fire({
imageUrl: 'https://placeholder.pics/svg/600x600',
imageWidth: 600,
imageHeight: 600,
confirmButtonText: 'Jai compris'
}).then(('load', function(event){

var $this = $(this);
$this.text('...');
var $imageSection     = $this.closest('.image-section');
var $colorThiefOutput = $imageSection.find('.color-thief-output');
var $targetimage      = $imageSection.find('.target-image');
showColorsForImage($targetimage, $imageSection);
})
);

console.log:

the variables are not defined

код, работающий с нажатием кнопки:

Swal.fire({
imageUrl: 'https://placeholder.pics/svg/600x600',
imageWidth: 600,
imageHeight: 600,
confirmButtonText: 'jai compris'
}).then((result) => {
$('.run-functions-button').click('load', function(event) {
    //Swal.fire('Any fool can use a computer')
var $this = $(this);
$this.text('...');
var $imageSection     = $this.closest('.image-section');
var $colorThiefOutput = $imageSection.find('.color-thief-output');
var $targetimage      = $imageSection.find('.target-image');
showColorsForImage($targetimage, $imageSection);
});
});

Мой вопрос: почему мои переменные не определены?Нажатие на кнопку является обязательным для загрузки функции?

1 Ответ

0 голосов
/ 24 апреля 2019
Swal.fire({
imageUrl: 'https://placeholder.pics/svg/600x600',
imageWidth: 600,
imageHeight: 600,
confirmButtonText: 'Jai compris'
}).then(('load', function(event){

var $this = $('.run-functions-button');
$this.text('...');
var $imageSection     = $this.closest('.image-section');
var $colorThiefOutput = $imageSection.find('.color-thief-output');
var $targetimage      = $imageSection.find('.target-image');
showColorsForImage($targetimage, $imageSection);
})
);
...