tags:

views:

23

answers:

1

I want to extend Dojo class _Scroller BUt the problem occurs because its declared in scope of another function

(function(){
 var nodeKids = function(inNode, inTag){
  var result = [];
  var i=0, n;
  while((n = inNode.childNodes[i++])){
   if(getTagName(n) == inTag){
    result.push(n);
   }
  }
  return result;
 };

 var divkids = function(inNode){
  return nodeKids(inNode, 'div');
 };

 dojo.declare("dojox.grid._Scroller", null, {
  constructor: function(inContentNodes){
                 ....
                }


          }
};

So when im doing like this to extend a scroller function


grid1.scroller.findScrollTop = dojo.hitch(grid1.scroller,  function(inRow){
divkids()
});

It cant find some functions. divkids() for example that you can see is not global, but located in a scope of some function; Please help;.

A: 

You can't access private variables in a closure, unless they're referenced from some other object outside of the closure's scope. So, if you need to use the code in divkids(), you could either duplicate the contents of that function and any private stuff it references, or you'd likely have to directly edit the file (put your stuff in the closure, or make it so the parts you need are not private)

peller