Reputation: 1816
I know this seems simple, but I am trying to include a javascript library in my spine app for reference in my spine classes. Any ideas how this is done?
Upvotes: 0
Views: 284
Reputation: 1583
The Spine documentation suggests using Hem to manage JavaScript/CoffeeScript dependencies.
Hem also allows you to specify static JavaScript libraries to include, under the "libs" option:
{
"libs": [
"./lib/other.js"
]
}
Hem isn't strictly necessary, though. You can include the library by explicitly using a script
tag in your HTML. Notice how other.js
is referenced in this modified version of index.html
from the Spine Contacts demo.
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8>
<title>App</title>
<link rel="stylesheet" href="/application.css" type="text/css" charset="utf-8">
<script src="/other.js" type="text/javascript"></script>
<script src="/application.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
var jQuery = require("jqueryify");
var exports = this;
jQuery(function(){
var App = require("index");
exports.app = new App({el: $("#article")});
});
</script>
</head>
<body>
<header id="header"><h1>Spine Contacts</h1></header>
<article id="article"></article>
</body>
</html>
Now any global-level objects or functions in other.js
are immediately accessible from any JavaScript/CoffeeScript in your application.
Upvotes: 3