这是在JavaScript类FileButton的
function FileButton(){
this.type = 'fileButton';
this.id ='uploadButton';
this.filebrowser = 'info:txtUrl';
this.label = "editor.lang.image.btnUpload";
this.forr = [ 'Upload', 'upload' ];
}
FileButton.prototype.onClick = function() {alert('hey')}
或者,如果你有JSON对象和要包装成JavaScript类对象,定义FileButton类和使用jQuery的:
function FileButton(){
this.type = 'fileButton';
this.id ='uploadButton';
this.filebrowser = 'info:txtUrl';
this.label = "editor.lang.image.btnUpload";
this.forr = [ 'Upload', 'upload' ];
}
FileButton.prototype.onClick = function() {alert('hey')};
var a = $.extend(new FileButton(), {
type : 'fileButton',
id : 'uploadButton',
filebrowser : 'info:txtUrl',
label : "editor.lang.image.btnUpload",
forr : [ 'Upload', 'upload' ],
onClick : function() {alert('hey')}
});
console.log(a);
a.onClick();
JsFiddle.net link
每一个运气,每一个搞清楚这一点? – davemackey 2010-06-23 20:52:43