Question

I would like to interact with the DOM immediately when the element becomes available. I can do this with a setInterval, but it won't work with Crossrider because the js that can interact with the DOM is only loaded once the DOM is ready. Any way to get aroind this?

Thanks

Was it helpful?

Solution

The current API doesn't officially support this feature at this time.

However, you're welcome to try our new appAPI.dom methods which work in Chrome and Firefox but are currently undocumented until they are officially released. The new methods are pretty self-explanatory, so I've listed them here with a brief description:

  • appAPI.dom.onDocumentStart.addJS(String jsCode, [Array siteList])
    This method adds the specified jsCode when the document starts to load. Optionally specify an array of strings/regex expressions (see http://docs.crossrider.com/#!/api/appAPI-method-isMatchPages for examples) specifying which URLs to add the code to.
  • appAPI.dom.onDocumentStart.addCSS(String cssRules, [Array siteList])
    This method adds the specified cssRules when the document starts to load. Optionally specify an array of strings/regex expressions (see http://docs.crossrider.com/#!/api/appAPI-method-isMatchPages for examples) specifying which URLs to add the CSS to.

OTHER TIPS

you might want to check out the appAPI.dom.onDocumentStart object because it doesn't seem to be defined even when called after appAPI.ready(). This is the error I'm getting:

Uncaught TypeError: Cannot call method 'addCSS' of undefined

Thanks! Keep up the good work!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top