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

how "public" is YAHOO.util.Connect._sFormData?

Expand Messages
  • Randal L. Schwartz
    I would like to do the following: YAHOO.util.Connect.setForm( my_form ); YAHOO.util.Connect._sFormData = YAHOO.util.Connect._sFormData + &async1=1 ;
    Message 1 of 4 , Jun 21, 2006
    • 0 Attachment
      I would like to do the following:

      YAHOO.util.Connect.setForm("my_form");
      YAHOO.util.Connect._sFormData = YAHOO.util.Connect._sFormData + "&async1=1";
      YAHOO.util.Connect.aSyncRequest('POST', my_url, my_connect);

      In other words, take everything from my form as it exists, and then also pass an additional
      flag so that I know this is one of my background requests and not the real form submission.

      However, this feels like a dirty reacharound, altering the data behind the scenes.

      Is ._sFormData going to be publicly supported in the future? Is there a better way to do what
      I want?

      How about refactoring setForm so that I can get the object back instead, and just add to it
      myself? That'd be better in the long run.
    • Philip Tellis
      ... Randal, if all your form submits happen via javascript and all are async, then you could do it with a hidden form variable called async1 with a default
      Message 2 of 4 , Jun 29, 2006
      • 0 Attachment
        Sometime on Jun 21, RLS cobbled together some glyphs to say:

        > I would like to do the following:
        >
        > YAHOO.util.Connect.setForm("my_form");
        > YAHOO.util.Connect._sFormData = YAHOO.util.Connect._sFormData + "&async1=1";
        > YAHOO.util.Connect.aSyncRequest('POST', my_url, my_connect);

        Randal, if all your form submits happen via javascript and all are
        async, then you could do it with a hidden form variable called async1
        with a default value of "" or 0.

        Then you set its value using javascript. You could set this value as
        soon as the hidden field is available.

        A dirtier solution may be needed if your form submissions may sometimes
        require this flag and sometimes not.

        I've also found that in most cases where I use an asyncRequest, I don't
        always want all the form data sent back. Most form data is just ignored
        for some kinds of requests. In such cases, it makes more sense to
        iterate through the form elements, creating your own content string with
        only the elements you want.

        Philip

        --
        Booze is the answer. I don't remember the question.
      • Randal L. Schwartz
        ... Yes, unfortunately, what I have is a big container form that has everything interesting on the page, and multiple buttons for user-driven actions.
        Message 3 of 4 , Jul 4, 2006
        • 0 Attachment
          --- In ydn-javascript@yahoogroups.com, Philip Tellis <philip.tellis@...> wrote:
          > Randal, if all your form submits happen via javascript and all are
          > async, then you could do it with a hidden form variable called async1
          > with a default value of "" or 0.
          >
          > Then you set its value using javascript. You could set this value as
          > soon as the hidden field is available.

          Yes, unfortunately, what I have is a big container form that has everything interesting on the
          page, and multiple buttons for user-driven actions. However, I also want to access some
          hidden state variables in my async request, and the "most lazy" method is to simply take the
          entire monster form and push it up via XHR, but with an extra flag that says "but this is to do
          async request #1".

          Thanks for your comment. I still need to confirm that my reacharound is not going to bite
          me in future YUI releases. If any Y! developer is paying attention, please tell me. Thanks.
        • Thomas S. Sha
          ... everything interesting on the ... want to access some ... method is to simply take the ... that says but this is to do ... reacharound is not going to
          Message 4 of 4 , Jul 4, 2006
          • 0 Attachment
            --- In ydn-javascript@yahoogroups.com, "Randal L. Schwartz"
            <merlyn@...> wrote:

            > Yes, unfortunately, what I have is a big container form that has
            everything interesting on the
            > page, and multiple buttons for user-driven actions. However, I also
            want to access some
            > hidden state variables in my async request, and the "most lazy"
            method is to simply take the
            > entire monster form and push it up via XHR, but with an extra flag
            that says "but this is to do
            > async request #1".
            >
            > Thanks for your comment. I still need to confirm that my
            reacharound is not going to bite
            > me in future YUI releases. If any Y! developer is paying attention,
            please tell me. Thanks.

            No guarantees. Since _sFormData isn't declared as a public member,
            you *may* run into issues if Connection Manager no longer requires
            this member. But, in all likelihood, that won't happen until a major
            version revision occurs.

            Regards,
            Thomas
          Your message has been successfully submitted and would be delivered to recipients shortly.