I am trying to use pre-existing functions in a new prototype class but
am having some trouble with binding.  When I call a function within a
function it says that one of my class variables is undefined.  I have
defined the class variable correctly I think:

  var DropDown = Class.create({
    initialize: function(date, appt_counter, times, edit_or_add) {
      this.start_drop_id = "start_drop_" + date + "_" + appt_counter;

Then in the following outside function, start_drop_id is errored as
being undefined:

    DropDown.prototype.show_block = function(element_id, element)
      if(document.getElementById(element_id).style.display == "block")
        outsideOf = null;
('stopObserving','click',this.outside); //stopObserving the outside
request as we have finished
          document.getElementById(element_id).style.display = "none";
      } else {
       outsideOf = element_id;
       document.getElementById(element_id).style.display =
        element.stopObserving('click',this.outside) //need to then
stop this from observing the outside - ie requires it at least

    DropDown.prototype.outside = function(event) {
      this.element = event.element();
      if( outsideOf == null ) {           //this shouldnt happen, but
just incase
      this.element = Event.element(event);
      if( this.element.descendantOf( $(outsideOf) ) !== true) {
        outsideOf = null;

        document.getElementById(this.start_drop_id).style.display =
"none";  //it says this is null

I think I need to use .bind(this) somewhere or maybe
bindAsEventListener?  I'm not sure.  This is my first time writing a
prototype class so I am bit lost.

You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to