Однако я генерирую все эти HTML с еще одним битом Javascript. Я думал, что это с обещанием, а затем инициализация Малле в тогдашней предложении должно сделать это, но это не так.
Код: Выделить всё
let promise = new Promise(function(resolve, reject) {
let t = "test";
createOutput();
resolve(t);
}).then((t) => {
console.log(t); //this works!
console.log(document.querySelectorAll('.percent')); // this works as well
// this still only targets the element that I put directly in the HTML
let malle = new Malle({
fun: (value, original, event, input) => {
console.log(`New text: ${value}`);
console.log(`Original element:`);
console.log(original);
return myFunctionReturningAPromiseString();
},
}).listen();
});
Подробнее здесь: https://stackoverflow.com/questions/796 ... -a-promise