cujojs/curl — Issue #66: Instances of objects not being kept separate
Author: SimpleAsCouldBe
Created: 2012-03-05 01:11:24+00:00
State: open

I thought at first maybe it was my ajaxy stuff mixing it up, but I constructed this very simple test case and it still mixes up the instances of objects.

Is there something I'm doing wrong here?

index.html

manager.js

define(
[
'test/wordPrinter'
]
,	function (WordPrinter) {
console.log('Executed Manager module');
var
// Public Methods
Manager
// Private Properties
,	_wordA
,	_wordB
;

//Constructor
Manager = function () {
console.log('Constructed Manager module');
_wordA = new WordPrinter('Abracadabraa');
_wordB = new WordPrinter('Bibliotechyo');
_bindEvents();
};

_bindEvents = function () {
$('body').click(function () {
console.log('Body element clicked');
ShowWords();
});
};

//Change the noun, joiner, and verb to the next one
ShowWords = function () {
console.log('Word A: ' + _wordA.get());
console.log('Word B: ' + _wordB.get());
};

// Public Exports
Manager.prototype = {
startTime: new Date()
,	showWords: ShowWords
};
return Manager;
}); //define

wordPrinter.js

define(
function () {
console.log('Executed randWordPicker module');
var
// Public
RandWordPicker
,	Get
// Private Vars
,	_word
;

//Constructor
RandWordPicker = function (word) {
console.log('Constructed randWordPicker module for this word: ' + word);
_word = word;
};

Get = function () {
return _word;
};

RandWordPicker.prototype = {
get:	Get
,	createTime: new Date()
};
return RandWordPicker;
}); //define