Loading ...
Sorry, an error occurred while loading the content.
 

Re: [ydn-javascript] connection manager problem

Expand Messages
  • Gopal Venkatesan
    ... The following might help you understand the problem: http://developer.yahoo.com/yui/connection/#scope -- Gopal Venkatesan http://gopalarathnam.com/weblog/
    Message 1 of 9 , Dec 3, 2007
      On Mon, Dec 03, 2007 at 12:55:02PM -0000, ragtek_ragga wrote:
      > hi
      > atm i'm trying to teach myself the connection manager
      >
      > so here's my example page:
      > http://www.ragtek.org/forum/todo.php
      > when i click on the "abfrage abschicken" button the connection manager
      > is activated and he recives the data
      > but he is not calling this.save
      >
      > can somebody look what i'm making false pls?
      > this is my object http://www.ragtek.org/forum/clientscript/todo.js
      >

      The following might help you understand the problem:

      http://developer.yahoo.com/yui/connection/#scope

      --
      Gopal Venkatesan

      http://gopalarathnam.com/weblog/
    • ragtek_ragga
      Isn t that exactly what i made? There stands: To use an object s method as a callback handler and maintain scope within the member, define the callback member
      Message 2 of 9 , Dec 3, 2007
        Isn't that exactly what i made?
        There stands:
        To use an object's method as a callback handler and maintain scope
        within the member, define the callback member scope with a value of this.

        And i did: scope: this


        Or am i missunderstanding something?
      • tssha
        ... this. ... Your scope reference is incorrect; using *this* within the callback object refers to itself. Instead, set scope to reference your factory
        Message 3 of 9 , Dec 3, 2007
          --- In ydn-javascript@yahoogroups.com, "ragtek_ragga"
          <ragtek_ragga@...> wrote:
          >
          > Isn't that exactly what i made?
          > There stands:
          > To use an object's method as a callback handler and maintain scope
          > within the member, define the callback member scope with a value of
          this.
          >
          > And i did: scope: this

          Your scope reference is incorrect; using *this* within the callback
          object refers to itself. Instead, set scope to reference your factory
          object. For example:

          var callback = {
          scope: vB_todo_Factory
          }

          Regards,
          Thomas
        • ragtek_ragga
          hi i think i m missunderstanding something do you mean: vB_todo_Factory.prototype.presave = function() { YAHOO.util.Connect.asyncRequest( GET ,
          Message 4 of 9 , Dec 3, 2007
            hi
            i think i'm missunderstanding something
            do you mean:

            vB_todo_Factory.prototype.presave = function()
            {
            YAHOO.util.Connect.asyncRequest("GET", "ajax.php?do=updatetodo", {
            success: this.save,
            failure: this.fehler,
            timeout: 5000,
            scope: vB_todo_Factory
            });

            }
          • Gopal Venkatesan
            ... Like I pointed you to the YDN example, the above call needs to be changed to: YAHOO.util.Connect.asyncRequest( GET , ajax.php?do=updatetodo , { success:
            Message 5 of 9 , Dec 3, 2007
              On Mon, Dec 03, 2007 at 07:12:26PM -0000, ragtek_ragga wrote:
              > hi
              > i think i'm missunderstanding something
              > do you mean:
              >
              > vB_todo_Factory.prototype.presave = function()
              > {
              > YAHOO.util.Connect.asyncRequest("GET", "ajax.php?do=updatetodo", {
              > success: this.save,
              > failure: this.fehler,
              > timeout: 5000,
              > scope: vB_todo_Factory
              > });
              >
              > }
              >
              >

              Like I pointed you to the YDN example, the above call needs to be
              changed to:

              YAHOO.util.Connect.asyncRequest("GET", "ajax.php?do=updatetodo", {
              success: vB_todo_Factory.save,
              failure: vB_todo_Factory.fehler,
              timeout: 5000,
              scope: vB_todo_Factory
              });

              HTH.

              --
              Gopal Venkatesan

              http://gopalarathnam.com/weblog/
            • ragtek_ragga
              hi that i had also tried yesterday i find out with: vB_todo_Factory.prototype.presave = function() { console.log( presave ); console.log({ success:
              Message 6 of 9 , Dec 3, 2007
                hi that i had also tried yesterday

                i find out with:

                vB_todo_Factory.prototype.presave = function()
                {
                console.log("presave");
                console.log({
                success: vB_todo_Factory.save,
                failure: vB_todo_Factory.fehler,
                timeout: 5000,
                scope: vB_todo_Factory
                });
                YAHOO.util.Connect.asyncRequest("GET", "ajax.php?do=updatetodo", {
                success: vB_todo_Factory.save,
                failure: vB_todo_Factory.fehler,
                timeout: 5000,
                scope: vB_todo_Factory
                });

                }
                that the success and the failure are undefinied
                i think i have to go back to the roots and read the chapter with the
                oop in js:D
              • Gopal Venkatesan
                ... Define vB_todo_Factory as a singleton to use like the above. var vB_todo_Factory = { presave: function () { // ... }, // ... }; this points to the
                Message 7 of 9 , Dec 3, 2007
                  On Tue, Dec 04, 2007 at 07:29:34AM -0000, ragtek_ragga wrote:
                  > hi that i had also tried yesterday
                  >
                  > i find out with:
                  >
                  > vB_todo_Factory.prototype.presave = function()
                  > {
                  > console.log("presave");
                  > console.log({
                  > success: vB_todo_Factory.save,
                  > failure: vB_todo_Factory.fehler,
                  > timeout: 5000,
                  > scope: vB_todo_Factory
                  > });
                  > YAHOO.util.Connect.asyncRequest("GET", "ajax.php?do=updatetodo", {
                  > success: vB_todo_Factory.save,
                  > failure: vB_todo_Factory.fehler,
                  > timeout: 5000,
                  > scope: vB_todo_Factory
                  > });
                  >
                  > }

                  Define vB_todo_Factory as a singleton to use like the above.

                  var vB_todo_Factory = {
                  presave: function () { // ... },
                  // ...
                  };

                  "this" points to the instance only if the function is called with
                  "new", otherwise "this" points to the global window object in context
                  of the web browser.

                  For example, check this:

                  var A = function() { this.a = 1; }

                  var x = new A();
                  alert(x.a);

                  var a = 2;
                  alert(a);

                  var y = A();
                  alert(a); // global object clobbered because of the previous line

                  --
                  Gopal Venkatesan

                  http://gopalarathnam.com/weblog/
                • ragtek_ragga
                  hi thx very much as singleton it s working
                  Message 8 of 9 , Dec 8, 2007
                    hi
                    thx very much
                    as singleton it's working
                  Your message has been successfully submitted and would be delivered to recipients shortly.