• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Prototype public method problem

I realize this one is pretty specific, but there are always bright people running around here so I thought I would give it a shot. Here's the situation:

I have a huge JS class that was created using prototype.js' class.create() function. That was managing things mostly fine, until we filled our database with about 2400 rows, which clearly is way to much to be binding to.

Immediate solution was to dump said huge list into an iFrame, and create one function that passes the value back to original JS class. I can pass the value back to the parent, and cannot for the life of me figure out how to call a method in the JS class from outside the class itself.
// Instantiation
var ahtree=new AhTree(<?= $user->getUserType() ?>);

// method definition inside the class
bla: function()
    alert('Inside bla');

// called from outside the class with

It keeps telling me that ahtree is not defined, but ahtree is doing plenty of other stuff, it's just the one call from outside the class that fails.

Any help is appreciated.

Hmmm once again, as soon as I post the question I come up with the answer. The theory described above works just fine, unless there is a JS error ANYWHERE in your class. So while the class appeared to be working fine, one of the elements I had moved to the iFrame was missing causing an error which I was diligently ignoring.

That little error is what was causing the browser to tell me that the object did not exist. Interesting, maybe it will help someone else out later.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.