Why it doesn’t work,it say its not a function,why can’t I call myalert() from myalert2?? How to do??
var sheepclass = function(handler) {
this.handler = $.extend({
'sizes': 'thin',
'eat': 'grass',
'color': 'white',
myalert: function() {
alert('Hello World');
},
myalert2: function() {
handler.myalert();
this.handler.myalert(); //this not work either
}
}, handler);
}
var blacksheep = new sheepclass({
'color': 'black'
});
blacksheep.handler.myalert2();
It’s because of the scope …
http://jsfiddle.net/78QXc/