Get 2024 Templates Mega Bundle!19 Bootstrap HTML, Vue & React Templates + 3 Vector Sets
Get for 99$

Delay drawer opening until loaded content (Craft)


Is there a way that I can delay the drawer opening by a second or so until it loads the body fully? I am using an embed in my drawer and sometimes the javascript to insert the src in the body of the drawer is delayed and causes a whitescreen drawer. Wanting to add this into the scripts.bundle.js of the drawer handling.


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 (3)


kt_drawer_example_dismiss



Hi,

This requirement can be done by populating the drawer content before showing it. You can attach an click event handler for a button and upon click you can load the content for the drawer body and display it via API:


var drawerToggle = document.querySelector("#kt_drawer_example_1_toggle");
var drawerElement = document.querySelector("#kt_drawer_example_1");
var drawer = KTDrawer.getInstance(drawerElement);

var drawerBodyElement = drawerElement.queryString("#kt_drawer_example_1_body");
object.addEventListener("click", myScript);
var contentLoaded = false;

drawerToggle.addEventListener("click", function() {
if (contentLoaded === false) {
drawerBodyElement.innerHTML = "Drawer content";
}
drawer.show();
});


Regards.



Hi,

May I know which drawer are you referring to? Also to customize the theme JS code you will need to edit the code in "src/js" and compile the changes into the assets folder. You should not edit scripts.bundle.js directly since it's compiled and minified code for production.

Please refer to to this Gulp Build Tools page to get starged with Craft assets management.

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  :(