Skip to content

Instantly share code, notes, and snippets.

@jmafc
Last active August 29, 2015 14:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmafc/800a0c05fc2d2fd71e91 to your computer and use it in GitHub Desktop.
Save jmafc/800a0c05fc2d2fd71e91 to your computer and use it in GitHub Desktop.
hello_component - update http://smalljs.org/package-managers/component-part-1/ to work with component@1.0.0-rc5
{
"name": "hello_component",
"dependencies": {
"component/dialog": "~0.2.0"
},
"scripts": ["index.js"]
}
<!doctype html>
<html>
<head>
<title>Hello Dialog</title>
<link href="build/build.css" rel="stylesheet">
</head>
<body>
<h1>Hello Dialog</h1>
<button onclick="openDialog()">Open</button>
<script src="build/build.js"></script>
<script>var openDialog = require("hello_component");</script>
</body>
</html>
var Dialog = require('dialog');
module.exports = function () {
var dialog = new Dialog('Hello World', 'Welcome human!')
.closable()
.modal();
dialog.show();
}
@timaschew
Copy link

watch out
if you put the <script> include to the end of your body, you cannot use functions above, unless they are executed immediately. In your case openDialog is not executed immediately, it's called if you click on the button.

@jmafc
Copy link
Author

jmafc commented Jun 17, 2014

@timaschew That is the intended behavior, as per the original post.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment