Skip to content

Instantly share code, notes, and snippets.

@rwaldron
Forked from phiggins42/inherited.html
Created January 24, 2011 15:49
<!DOCTYPE html>
<html>
<head>
<title>Dojo x-domain Skeleton</title>
<script src="http://ajax.googleapis.com/ajax/libs/dojo/1.5/dojo/dojo.xd.js"></script>
<script>
// the superclass
dojo.declare("Foo", null, {
bar:function(){
console.warn("Foo's bar");
},
baz: function(){
console.warn("Foo's baz");
},
bam: function(){
console.warn("Foo's bam");
}
});
// declare() supports unnamed inherited()
dojo.declare("Bar", Foo, {
bar: function(){
console.warn("Bar's bar");
this.inherited(arguments);
}
});
// using dojo.extend() you have to name the inherited()
dojo.extend(Bar, {
baz: function(){
console.warn("Bar's extended baz");
this.inherited("baz", arguments);
}
});
// declare() adds an .extend() to the OBJECT (not .proto)
// does not require name in inherited()
if("extend" in Bar){
Bar.extend({
bam: function(){
console.warn("Bar's .extended bam");
this.inherited(arguments);
}
})
}
dojo.ready(function(){
var b = new Bar();
b.bar(); b.baz(); b.bam();
});
</script>
</head>
<body class="claro">
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment