Since I lost one hour on it
It works fine on DIVs, but not on other elements (e.g. SELECT or INPUT).
Maybe update the docs by saying "where" it works, because it took me quite a while to debug it - it would correctly let me create the instance, only to be empty with no block/release methods.
Also, maybe you can add into the doc that a simple example
---
const blockUIInstances = {};
function blockIt(id) {
if (blockUIInstances[id]) {
return; // If it already exists, do nothing
}
const targetElement = document.querySelector("#"+id);
if (targetElement) {
blockUIInstances[id] = new KTBlockUI(targetElement);
console.log('KTBlockUI instance:', blockUIInstances[id]);
if (typeof blockUIInstances[id].block === 'function') {
blockUIInstances[id].block(); // Activate the spinner
} else {
console.error(`block() method not found on KTBlockUI instance for target: ${id}`);
}
} else {
console.error(`Element with ID '${id}' not found in the DOM.`);
}
return
}
function releaseIt(id) {
if (blockUIInstances[id]) {
console.log('deleting '+id)
blockUIInstances[id].release(); // Deactivate the spinner
delete blockUIInstances[id]; // Remove the instance
}
return
}
---
so that you can have dynamic ones according to the id, without the need to create static ones
Your suggestions for improving the documentation to specify the working conditions of the implementation and to include a dynamic example are quite valuable. Lows Adventures 2
Hi,
Yes, you will need to wrap input elements with container div and apply the blockUI on the div element.
Sure, we will update the docs.
Regards.