After a great help from Sam Gladstone from Knack I have managed to have all my JS and CSS code out of Knack. I do not experience any kind of scope problems you mention.
My setup is like this:
- My Knack app is embedded on my own website
- I am using Rapidweaver for Mac to create my website - it is easy to use but not pro in terms of direct coding, so I am not doing that inside Rapidweaver
- instead I am using TextWrangler to edit my css and JS files directly on website (with local copy)
- I am using the following code in JS editor i Knack:
// load external CSS files
var css_files = [cssFile_url];
LazyLoad.css(css_files, function () {
console.log('External CSS-es have been loaded');
});
// load JS files in such a way that all Knack event handlers will work
KnackInitAsync = function ($, callback) {
window.$ = $;
LazyLoad.js([jsFile_url], function () {
console.log(‘External JS file have been loaded’);
callback();
});
}
I tried before Lazyload with wrapping for Knack.init() but this method described in Knack documentation does not work for Knack event handlers. Solution above provided by Sam resoled the problem.
So as to now I am able to do all my programming outside of Knack.
Andrzej