Skip to content

Commit

Permalink
JS prototypes
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason committed Jun 3, 2014
1 parent c63dd0f commit 3763268
Show file tree
Hide file tree
Showing 4 changed files with 1,429 additions and 0 deletions.
42 changes: 42 additions & 0 deletions jsProto.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@



var J = function(){
this.initialize();



};


_.extend(J.prototype, {

initialize: function(){
this.self = this;
var self = this;
console.log("!");
self.blah.apply({ a: 6}, []);
var mmmmm = new self.blah();
setTimeout(self.blah, 10);

setTimeout(function(){self.blah()}, 500);
//$(document).on('click', this.click);
console.log("---end--");

},

blah: function() {
console.log(this);
console.log("should be..... a number:", this.a);
},

click: function() {
//console.log(this.a);
}


});



new J();
40 changes: 40 additions & 0 deletions test/testBindAll.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,45 @@ var vv = new (Backbone.View.extend({




var J = function(){
this.initialize();



};


_.extend(J.prototype, {

initialize: function(){
debugger;
this.self = this;
console.log("!");
self.blah.apply({ a: 6}, []);
var mmmmm = new self.blah();
setTimeout(self.blah, 10);

setTimeout(function(){self.blah()}, 500);
//$(document).on('click', this.click);
console.log("---end--");

},

blah: function() {
console.log("should be..... a number:", self.a);
},

click: function() {
//console.log(this.a);
}


});



new J();
//////

//
Expand Down Expand Up @@ -72,3 +111,4 @@ new c();
x = p.extend({"a": "hahaha"})


new x();
4 changes: 4 additions & 0 deletions tmp.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<script src="underscore.js"></script>


<script src="jsProto.js"></script>
Loading

0 comments on commit 3763268

Please sign in to comment.