Christmas Sale! Limited Time Only - Enjoy 30% Off Metronic Extended License!
Buy for 669$  969$

TypeError: blockElement.release is not a function


Hello, I am trying to block an element while data is loading. I am using Metronic 8 alongside Bootstrap 5. I can succesfully block the element but I cannot release it and i get an error, I created a MVP


async function getModelActivity(modalElem) {
blockModal(modalElem.id);

unblockModal(modalElem.id);
}


function blockSection(HTMLElement) {
const blockElement = new KTBlockUI(HTMLElement);

return blockElement.block();
}

function unblockSection(HTMLElement) {
const blockElement = new KTBlockUI(HTMLElement);

return blockElement.release();
}

function blockModal(selector) {
const longSelector = "#" + selector + " .modal-content";
const elem = document.querySelector(longSelector);

return blockSection(elem);
}

function unblockModal(selector) {
const longSelector = "#" + selector + " .modal-content";
const elem = document.querySelector(longSelector);

return unblockSection(elem);
}


I call the getModelActivity function. And i get the error TypeError: blockElement.release is not a function
at unblockSection


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (2)


Hi,

Can you please follow Block UI ?

"is not a function" means you are accessing the variables from different scope. Can you make sure that not a block element is accessible when you call it ?

It seems this is not a Metronic issue, it's more likely your code issue.

Regards.



Hi,

Sorry for the late reply. We will check it shortly and get back to you asap.

Regards.


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(