I have one page, that load new elements via jquery. I have page that have event listener like
ipcRenderer.send('getlist');
ipcRenderer.once('return:list', function (e, l, wn) {
console.log('a');
for(let i = 0; i < l.length; i++) {
$('.a').append('<div>'+l[i]+wn[i]'</div>');
}
$('.a').append('<div>End</div>');
});
Code that send data to page:
ipcMain.on('getlist', function (e) {
wn = [];
cfg['a'].forEach(s => {
wn.push(yaml.readSync('charcfg.yaml')['name']);
});
mainWindow.webContents.send('return:list', cfg['a'], wn);
});
And it's works perfectly until I load another page, and again load this page. This event fires multiple times. Each time I come back to this page, more times it goes.
I tried to use
ipcRenderer.once('someevent', function(e, l){...});
It's works only ONE TIME. On third reload it's starts do listener multiple times again.
Code with this script loads with page!
Sorry for my english.Output
Function that loads page via jquery:
const htmlContent = $('.content');
function setContent(s) {
$('.content').animate({
opacity: 0
}, 200, function () {
setTimeout(function () {
htmlContent.load(s + '.html');
$('.content').animate({
opacity: 1
}, 200);
}, 100);
});
}