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

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


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