Docsify: Init javascript on the page, after it has been loaded.

Created on 6 Jul 2017  路  2Comments  路  Source: docsifyjs/docsify

Is there an event I can listen to on each page to init some small js i wrote? Now its initializing before the dom is parsed.

Most helpful comment

This can be accomplished using docsify's plugin architecture:

// Plugin
function doSomething(hook, vm) {
  hook.doneEach(function() {
    // Do something...
  });
}

// Add to plugin array
$docsify.plugins = [].concat(doSomething, $docsify.plugins);

All 2 comments

I'm walking around the same issue, encaspulate the code into something like:

window.addEventListener('DOMContentLoaded', () => {
    setTimeout(() => {
      microlink('.demo-link', {
        rounded: true
      })
    }, 200)
  })

It's too tricky. Ideally, docsify could emit an event when the page is mounted:

window.addEventListener('docsify:ready', () => {
      microlink('.demo-link', {
        rounded: true
      })
  })

This can be accomplished using docsify's plugin architecture:

// Plugin
function doSomething(hook, vm) {
  hook.doneEach(function() {
    // Do something...
  });
}

// Add to plugin array
$docsify.plugins = [].concat(doSomething, $docsify.plugins);
Was this page helpful?
0 / 5 - 0 ratings