So, I am building a pretty complicated plugin and ran into a snag. (This is how I learn though, so snags are good...) My code looks similar to the following:
Document 1
if( !window.TextEdit ){
var TextEdit = {"version": "1.0"};
}
TextEdit.edit = function(context, options) {
var self = this;
self.context = context;
self.buttonDef = {
bold: {
class: 'bold',
command: 'bold',
icon: 'bold',
type: 'checkbox',
label: ''
},
italic: {
class: 'italic',
command: 'italic',
icon: 'italic',
type: 'checkbox',
label: ''
},
underline: {
class: 'underline',
command: 'underline',
icon: 'underline',
type: 'checkbox',
label: ''
}
}
self.init();
}
Document 2
if( !window.TextEdit.imageload ){
TextEdit.imageload = {"version": "1.0"};
}
TextEdit.imageload = function() {
var self = this;
self.editor = TextEdit;
self.init();
}
TextEdit.imageload.prototype = {
init: function() {
var self = this;
console.log(self.buttonDef);
$('.tdt-btn-addimage').click(function() {
});
},
create: function() {
},
destroy: function() {
}
}
new TextEdit.imageload();
So, using Document 2 I want to access the variable self.buttonDef in Document 1. I am able to access the functions in Document 1 just fine, but not the variables.
What I am looking for is how to make buttonDef
a property of TextEdit
.