Hi,
I’m trying to “reload” a class and I need help figuring out if I’m doing this correctly. I’m using MojoZoom as an example, but I consider this a general AJAX/JavaScript question.
MojoZoom is a simple class that adds zooming to an existing image. The problem, is that my image gallery works by changing the <img> “src” in Ajax so when you click a thumbnail for another image you see the new image but the zoomed part still uses the default one. This is probably because the MojoZoom class initialized only on page load, so I need to “reload” it.
The code for MojoZoom is 99% similar to this code I found online so you can see it: [url]http://code.google.com/p/feeling-luckier/source/browse/trunk/html/script/mojozoom.js?r=6
As you can see the original class is defined like this:
[CODE]var MojoZoom = (function() {
function init(){
}
})();
I’ve edited mine to be more like:
[CODE]function MojoZoom(){
function init(){
}
this.init = init;
}
I made the changes because I was hoping it would allow me to do: var Mojo = MojoZoom(); when I wanted to “reload” it but that didn’t seem to work. Maybe because I need to dispose of the previous class somehow?
Thanks