Super Sale Limited Time 50% OFF for All-Access Plans
Save 50% Now

How to use BlockUI with Vue3 App?


Hello,
I'm using Metronic 8.1.5 with Vue3, and I'm trying to use the BlockUI (following the documentation https://preview.keenthemes.com/html/metronic/docs/general/blockui) but the KTBlockUI is not recognized.

How can I use that BlockUI component?

Thanks


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (3)


Hi Amit,

You need to import the KTBlockUI instance from the file src/js/components/blockui.js.

Then you can use this instance as shown in our documentation.

var button = document.querySelector("#kt_block_ui_1_button");
var target = document.querySelector("#kt_block_ui_1_target");

var blockUI = new KTBlockUI(target);

button.addEventListener("click", function() {
if (blockUI.isBlocked()) {
blockUI.release();
button.innerText = "Block";
} else {
blockUI.block();
button.innerText = "Release";
}
});


Regards,
Lauris Stepanovs,
Keenthemes Support Team



This following line "new KTBlockUI(target);" returns "KTBlockUI is not recognized"

Is there anything I should do to include/import KTBlockUI?



Hi,

KTBlockUI class is located in the file src/js/components/blockui.js, you need to copy this file from our HTML version and paste it into your project, then import this class to your component.

Make sure to add export code to file blockui.js.

export default KTBlockUI


Then import it into your component.

import KTBlockUI from "@/path/to/blockui.js"


Regards,
Lauris Stepanovs,
Keenthemes Support Team


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(