-
-
Save zhuochun/2930223 to your computer and use it in GitHub Desktop.
Ti.include, browser, and CommonJS module
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//CommonJS style | |
var mod = require('browser.ti.module'); | |
mod.sayHello('Kevin'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Ti.include style | |
Ti.include('browser.ti.module.js'); | |
globalNamespace.sayHello('Kevin'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//This variable will be the public interface | |
//of the module in a script tag or Ti.include | |
var globalNamespace = {}; | |
(function (exports) { | |
exports.sayHello = function(str) { | |
alert('Hello '+str+'!'); | |
}; | |
}(typeof exports === 'object' && exports || globalNamespace)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script src="browser.ti.module.js" type="text/javascript" charset="utf-8"></script> | |
<script type="text/javascript" charset="utf-8"> | |
//browser style | |
globalNamespace.sayHello('Kevin'); | |
</script> | |
</head> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment