renderTree: function(){ var tree = this; $.post("/Treeview?task=GET_NODE&action=DYNAMIC", {}, function() { tree.renderFolder(xml, 'foldersView'); }); },
On Feb 5, 5:54 pm, MoBel <morrybel...@gmail.com> wrote: > I'm integrating prototype and jQuery together. I have a class that > looks like this: > > var TreeView = function(){}; > TreeView.prototype = { > initialize: function() > { > this.view = 'Data management'; > }, > > renderTree: function() > { > $.post("/Treeview?task=GET_NODE&action=DYNAMIC", {}, function > () { this.renderFolder(xml, 'foldersView'); } ); > }, > > renderFolder: function(xml, outputDiv) > { > // do some stuff > } > > } > > var treeview = new TreeView(); > > Obviously this doesn't work because this does not refer to the my > treeview instance of the TreeView object. > > I've also tried doing this with $.post > $.post("/Treeview?task=GET_NODE&action=DYNAMIC", {}, function > () { this.renderFolder(xml, 'foldersView'); }.bind(this) ); > > But that doesn't seem to help. > > So my question is, is there a way to get around this? Should I be > writing my TreeView object in a different way?