Your this scope is lost inside the "this.exito" method.  You need to
use a closure, via the bind method to ensure the instance's reference
is maintained in the asynchronous callbacks.

onSuccess : this.exito.bind(this)



On Sep 22, 10:14 am, "Miguel Beltran R." <[EMAIL PROTECTED]> wrote:
> I don't know what do you meant but if I change
>
> onSuccess: this.exito,
>
> to
>
> onSuccess: function (transport){
> alert(3);
>    var XML = transport.responseXML.documentElement;
>    var response = XML.getElementsByTagName('respuesta')
> [0].childNodes[0].nodeValue;
>    if (response == 'bien'){
>       var accion = XML.getElementsByTagName('accion')
> [0].childNodes[0].nodeValue;
>       if (accion=='alta'){
>           this.exito_alta(XML);                   <---- Here stop, no
> call the function
>       }else if(accion=='modificar'){
>           this.exito_modificar(XML);
>       }else if(accion=='eliminar'){
>           this.exito_eliminar(XML);
>       }
>    }else{
>       var error_type = XML.getElementsByTagName('error_type')
> [0].childNodes[0].nodeValue;
>       var error_description =
> XML.getElementsByTagName('error_description')
> [0].childNodes[0].nodeValue;
>      // var content_error = ;
>       str = '<strong>Placa:</strong>' + $('bplac').value +
> '<br><strong>Error tipo:</strong>' + error_type +
>            '<br><strong>Descripcion:</strong>' + error_description;
>       $('estado').update(str);
>    }
>  },
>
> })
>
> I added to my Class initialize but not work :(
> var Taller = Class.create({
>   initialize: function() {
>      this.exito.bind(this);
>      this.exito_alta.bind(this);
>   },
>
> 2008/9/19 jason maina <[EMAIL PROTECTED]>:
>
>
>
>
>
> > yourpadre,
> > I stand to be corrected here, but most prototype methods/functions
> > start with lower case eg onCreate, onFailure etc
>
> > Do refer to prototype documentation for actual method/function names.
>
> > Regards
> > jason
>
> > On 9/19/08, yourpadre <[EMAIL PROTECTED]> wrote:
>
> >> Hi List
>
> >> I try this
> >> 1.- The submit form call mitaller.alta
> >> 2.- Popup alert(1)
> >> 3.- The data is corrected inserted in database
> >> 4.- I expected this.exito run, but not
> >> 5.- Popup alert(2)
>
> >> Why "exito" not run OnSuccess?
> >> If change it to: onSuccess: alert("popup") yes work fine.
>
> >> var Taller = Class.create({
> >>   alta: function (event){
> >>     event.stop();
> >> alert(1);
> >>     new $('main_form').request({
> >>                  parameters: $('main_form').serialize(),
> >>                  onSuccess: this.exito,
> >>                  onFailure: this.error
> >>              });
> >> alert(2);
> >>   },
>
> >>   exito: function (transport){
> >> alert(3);
> >>     var XML = transport.responseXML.documentElement;
> >>     var response = XML.getElementsByTagName('respuesta')
> >> [0].childNodes[0].nodeValue;
> >>     if (response == 'bien'){
> >>        var accion = XML.getElementsByTagName('accion')
> >> [0].childNodes[0].nodeValue;
> >>        if (accion=='alta'){
> >>            exito_alta(XML);
> >>        }else if(accion=='modificar'){
> >>            exito_modificar(XML);
> >>        }else if(accion=='eliminar'){
> >>            exito_eliminar(XML);
> >>        }
> >>     }else{
> >>        var error_type = XML.getElementsByTagName('error_type')
> >> [0].childNodes[0].nodeValue;
> >>        var error_description =
> >> XML.getElementsByTagName('error_description')
> >> [0].childNodes[0].nodeValue;
> >>       // var content_error = ;
> >>        str = '<strong>Placa:</strong>' + $('bplac').value +
> >> '<br><strong>Error tipo:</strong>' + error_type +
> >>             '<br><strong>Descripcion:</strong>' + error_description;
> >>        $('estado').update(str);
> >>     }
> >>   },
> >> })
>
> >> var mitaller = new Taller();
> >> document.observe('dom:loaded', function(){
> >>    $('main_form').observe('submit', mitaller.alta);
> >> });
>
> > --
> > Sent from Gmail for mobile | mobile.google.com
>
> --
> ________________________________________
> Lo bueno de vivir un dia mas
> es saber que nos queda un dia menos de vida
--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to