在用户关闭模式后加载功能
Load a function after the user closed a modal
我正在使用一个名为 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);
});
});
我的问题是为什么我的变量没有定义?单击按钮是加载功能的义务吗?
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);
}));
我正在使用一个名为 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);
});
});
我的问题是为什么我的变量没有定义?单击按钮是加载功能的义务吗?
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);
}));