Copy to ClipboardReference: [www.bkjia.com]/*
* Create confirmation dialog box
* @ Constructor ConfirmBox
*/
Var ConfirmBox, confirmOff, confirmDel;
ConfirmBox = function (msg, url ){
This. msg = msg;
This. url = url;
};
ConfirmBox. prototype. fire = function (e ){
Var message = confirm (this. msg );
If (message ){
Window. location. href = this. url;
}
};
/*
* Are you sure you want to dismount this project?
* @ Instance confirmOff
*/
ConfirmOff = new ConfirmBox ('Are you sure you want to dismount this project? ', Config. offUrl );
If (Y. all ('. sale-off ')){
Y. on ('click', confirmOff. fire, '. sale-off', confirmOff );
}
Due to the encapsulation mechanism of YUI3, the default context environment for event registration through Y. on is Y object. In a JavaScript constructor, when the prototype method calls this, it points to the instantiated object itself. If the context is not reset to the instance itself, it goes down. If it is not reset, the console. log this. msg attribute is the following: