Open clark-pan opened 9 years ago
Running into the exact same issues including jailed with require.js
I had to make the following changes to make it work:
__jailed__path__
is set from window.__jailed__path__
if defined (then I just have to set that in my code before loading jailed)initWeb
I check document.readyState
to decide whether to manually run the load code (the window.onload
event has already been missed)I was having the same issues. Using JSPM to install jailed (jspm install jailed=github:asvd/jailed@0.3.1
).
Other than the solution posted by @dgrad you can also include the following in your index.html head tag: <script src="jspm_packages/github/asvd/jailed@0.3.1/lib/jailed.js"></script>
I used this to get around my problems including it in Angular
<script src="https://unpkg.com/jailed@0.3.1/lib/jailed.js"></script>
Its quite difficult to use jailed in lazy loading system like require.js or systemJS at the moment.
A couple of problems:
__jailed__path__
calculation doesn't get it right. It makes the assumption that the script is loaded synchronously. If the async or defer attrs is used on the script tag, or something like requirejs or systemJS is used, the base path will be wrong. This should be configurable somehow, maybe by taking the value if it already exists (var __jailed__path__ = __jailed__path__ || //...
)initWeb
listens towindow.onload
, if you lazy load jailed, the initialisation never happens.document.readyState
should be checked. For a simple implementation check doc-ready