Skip to content

Instantly share code, notes, and snippets.

@cschneid
Created September 22, 2010 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cschneid/77c51808d1890814b024 to your computer and use it in GitHub Desktop.
Save cschneid/77c51808d1890814b024 to your computer and use it in GitHub Desktop.
<html>
<body>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/jquery-ui.min.js" type="text/javascript"></script>
<script type="text/javascript">
$.widget("cb.hello", {
_init: function(){
alert("Hello Widget Ran");
}
});
$(function(){
$("#thing").hello();
});
$.cb.hello.prototype // => is that widget
$.ui.hello.prototype // => null.
// Namespaces only affect the spot in the heirarchy where the widget code
// gets put. There's still a giant name collision waiting to happen with the
// name of the widget itself (`hello` in this case).
</script>
<div id="thing">Attach hello to me please</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment