Custom Javascript & CSS

09/05/2013 Posted by Brandon

We're pleased to announce an exciting new feature: the ability to add custom Javascript and CSS code directly to your apps!

One of the strongest features about Knack is that designers and developers can easily use jQuery and CSS to customize each app.

Until now, this was only possible by first publishing your Knack app to your own website and adding the code there. Any code you applied wouldn't be available on the hosted Knack apps at knack.com. So if you weren't interested in publishing your app to your own site you were out of luck.

We've now added the ability to add this code directly into your app, so it can be applied to both hosted and published apps. We've combined it with the API tab under Settings:

There are separate editors for both JavaScript and CSS. Each editor is color-coded and will follow common syntax highlighting for those languages.

Some notes about this custom code:

  • Any code added will be called after all Knack code and styles have been loaded.
  • You don't need to wrap the JavasScript code in window.KnackInit().
  • JavaScript code has access to the Knack $ jQuery object.
  • The code is called for every load regardless of which scene is first viewed.
  • You can still add code and CSS to your site if you want to limit customization just to your published apps.
Please note that although we're providing these tools we can't debug or add code for you. If you'd like us to provide these services please consider filling out a request here:

https://www.knack.com/custom-development/