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

Re: connection manager problem

Expand Messages
  • 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 1 of 9 , Dec 3, 2007
    • 0 Attachment
      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 2 of 9 , Dec 3, 2007
      • 0 Attachment
        --- 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 3 of 9 , Dec 3, 2007
        • 0 Attachment
          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 4 of 9 , Dec 3, 2007
          • 0 Attachment
            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 5 of 9 , Dec 3, 2007
            • 0 Attachment
              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 6 of 9 , Dec 3, 2007
              • 0 Attachment
                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 7 of 9 , Dec 8, 2007
                • 0 Attachment
                  hi
                  thx very much
                  as singleton it's working
                Your message has been successfully submitted and would be delivered to recipients shortly.