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

Re: [ydn-javascript] overriding onsubmit default behavior

Expand Messages
  • Nige White
    ... An event listener on the form for the submit event which calls preventDefault() works for me.
    Message 1 of 5 , Jun 2, 2006
      gib wrote:

      > This is a great question. Is this a case where you may not want a
      > Listener? It seems like this behavior is correct... addListener
      > appends rather than overrides, the default event handling is to post
      > the form so that gets executed while the added event handler is
      > waiting in the wings. Anything after the form post wouldn't get
      > called. Maybe the preventDefault and stopEvent methods of
      > YAHOO.util.Event would be helpful here.
      >
      An event listener on the form for the "submit" event which calls
      preventDefault() works for me.

      _____________________________________________________________________
      This message has been checked for all known viruses. Virus scanning
      powered by Messagelabs http://www.messagelabs.com For more information
      e-mail : hostmaster@...
    • matt snider
      You re right, if i use YAHOO.util.Event.preventDefault(e); in my callback function it stops the default behavior. stopEvent also works. -matt
      Message 2 of 5 , Jun 2, 2006
        You're right, if i use

        YAHOO.util.Event.preventDefault(e);

        in my callback function it stops the default behavior. stopEvent also works.

        -matt

        On 6/2/06, gib <gib.reimschussel@...> wrote:
        This is a great question.  Is this a case where you may not want a Listener?  It seems like this behavior is correct... addListener appends rather than overrides, the default event handling is to post the form so that gets executed while the added event handler is waiting in the wings.  Anything after the form post wouldn't get called.  Maybe the preventDefault and stopEvent methods of YAHOO.util.Event would be helpful here.

        I guess you could always bind/add a listener to the previous event (button click maybe?) and let the flow continue into the form post or return false/stop that event...?


        On 6/2/06, Matt <mattsniderppl@... > wrote:
        i'm converting my site's DOM 1.0 style javascript, with dhtml calls as
        tag attributes, to the DOM 2.0 eventListener functions provided in the
        Yahoo javascript API. However, i can't figure out how to prevent my
        forms from submiting when trying to capture the onsubmit event. I used
        to add return false, but i don't see how that is done in the
        eventListener method.

        the add listener line, looks like this.

        YAHOO.util.Event.addListener("myform", "submit", eventCallback);

        the eventCallback funtion is not being trigger before the form is
        submitted.

        If someone could help me or steer me in the right direction of the
        solution, i would appreciate it.

        thanks,
        -matt





        SPONSORED LINKS
        C programming language Computer programming languages Java programming language
        The c programming language C programming language Concept of programming language


        YAHOO! GROUPS LINKS






        SPONSORED LINKS
        C programming language Computer programming languages Java programming language
        The c programming language C programming language Concept of programming language


        YAHOO! GROUPS LINKS




      • Eric Miraglia
        Matt, Note that stopEvent is both preventing the default action — the form s submission in this case — and stopping the event s propagation or bubbling
        Message 3 of 5 , Jun 2, 2006
          Matt,

          Note that stopEvent is both preventing the default action — the form's submission in this case — and stopping the event's propagation or "bubbling" up through the DOM.  The only piece of this you need for intervening and stopping the form submission is preventDefault; there may be no harm in using stopEvent to also effect a stopPropagation, but be aware that stopEvent has that dual impact on the event's behavior.

          Regards,
          Eric


          On Jun 2, 2006, at 5:44 AM, matt snider wrote:

          You're right, if i use

          YAHOO.util.Event.preventDefault(e);

          in my callback function it stops the default behavior. stopEvent also works.

          -matt

          On 6/2/06, gib <gib.reimschussel@...> wrote:
          This is a great question.  Is this a case where you may not want a Listener?  It seems like this behavior is correct... addListener appends rather than overrides, the default event handling is to post the form so that gets executed while the added event handler is waiting in the wings.  Anything after the form post wouldn't get called.  Maybe the preventDefault and stopEvent methods of YAHOO.util.Event would be helpful here.

          I guess you could always bind/add a listener to the previous event (button click maybe?) and let the flow continue into the form post or return false/stop that event...?


          On 6/2/06, Matt <mattsniderppl@... > wrote:
          i'm converting my site's DOM 1.0 style javascript, with dhtml calls as
          tag attributes, to the DOM 2.0 eventListener functions provided in the
          Yahoo javascript API. However, i can't figure out how to prevent my
          forms from submiting when trying to capture the onsubmit event. I used
          to add return false, but i don't see how that is done in the
          eventListener method.

          the add listener line, looks like this.

          YAHOO.util.Event.addListener("myform", "submit", eventCallback);

          the eventCallback funtion is not being trigger before the form is
          submitted.

          If someone could help me or steer me in the right direction of the
          solution, i would appreciate it.

          thanks,
          -matt





          SPONSORED LINKS
          C programming language Computer programming languages Java programming language
          The c programming language C programming language Concept of programming language


          YAHOO! GROUPS LINKS






          SPONSORED LINKS
          C programming language Computer programming languages Java programming language
          The c programming language C programming language Concept of programming language


          YAHOO! GROUPS LINKS






          SPONSORED LINKS
          C programming language Computer programming languages Java programming language
          The c programming language C programming language Concept of programming language


          YAHOO! GROUPS LINKS





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