Hi all,

I'm having a problem with an Ajax.Request. I can't figure out how I
can pass an event (an onclick on a checkbox) which causes the Ajax
Request, to be recognized in an onSuccess function. Here's my
simplified code:

var RequiredField = Class.create();

RequiredField.prototype = {
  initialize: function(chkbox) {
  this.chkbox = chkbox;
  this.chkbox.onclick = this.switchRequired.bindAsEventListener(this);
},
        
switchRequired: function(evt) {
  this.evt = evt; // Set the event to a property
  alert(this.evt);
  var params = $F(this.chkbox);
  var myAjax = new Ajax.Request('server/checkRequired.html',
        {method: 'get', parameters: params, onSuccess: this.switchPrompt
,onFailure: this.dontCheck}
},
        
switchPrompt: function() {
  alert(this.evt); // Try to pick up the this.evt var, but it comes
bakc as undefined
},
        
dontCheck: function(response) {
  // failure
}
}
_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs

Reply via email to