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

Dialog: Submit vs Upload and Hitting Enter

Expand Messages
  • Hans Zaunere
    Hello, It appears that there is different behavior between pressing enter and clicking submit for a Dialog based form. It s most notable when there s a file
    Message 1 of 3 , Jan 31, 2009
    • 0 Attachment
      Hello,

      It appears that there is different behavior between pressing enter and
      clicking submit for a Dialog based form. It's most notable when there's a
      file input.

      For example, when a user actually clicks Submit, both the success and upload
      callbacks are called. When a user simple hits enter, only the upload
      callback is called.

      Is there a way to change this behavior so that it's more reliable. Or at a
      minimum a way to know if the success callback has fired, so that code in
      both places isn't executed twice.

      Thanks.

      ---
      Hans Zaunere / Managing Member / New York PHP
      www.nyphp.org / www.nyphp.com
    • kfish_22
      Here s a piece of code to define a special behavior for the key - or any key for that matter, as long as you write a handler for the key s numeric
      Message 2 of 3 , Feb 1, 2009
      • 0 Attachment
        Here's a piece of code to define a special behavior for the <Enter>
        key - or any key for that matter, as long as you write a handler for
        the key's numeric code.

        >>> Begin snippet

        nn=(document.layers)?true:false;
        ie=(document.all)?true:false;
        function keyDown(e) {
        var evt=(e)?e:(window.event)?window.event:null;
        if(evt){
        var key=(evt.charCode)?evt.charCode:((evt.keyCode)?
        evt.keyCode:((evt.which)?evt.which:0));
        // Enter key = 13
        if(key==13){
        // Do you own processing for the Enter key.
        myCustomFunction();
        // Return false to prevent the default browser behavior
        return false;
        }
        }
        }
        document.onkeydown=keyDown;
        if(nn) document.captureEvents(Event.KEYDOWN);

        <<< End Snippet

        Cheers,
        Kevin

        --- In ydn-javascript@yahoogroups.com, "Hans Zaunere" <lists@...>
        wrote:
        >
        > Hello,
        >
        > It appears that there is different behavior between pressing enter
        and
        > clicking submit for a Dialog based form. It's most notable when
        there's a
        > file input.
        >
        > For example, when a user actually clicks Submit, both the success
        and upload
        > callbacks are called. When a user simple hits enter, only the
        upload
        > callback is called.
        >
        > Is there a way to change this behavior so that it's more reliable.
        Or at a
        > minimum a way to know if the success callback has fired, so that
        code in
        > both places isn't executed twice.
        >
        > Thanks.
        >
        > ---
        > Hans Zaunere / Managing Member / New York PHP
        > www.nyphp.org / www.nyphp.com
        >
      • Satyen Desai
        Hi Hans, I don t see the behavior you refer to with the following example, which has a file input field, a text input field, a native HTML submit button and a
        Message 3 of 3 , Feb 3, 2009
        • 0 Attachment
          Hi Hans,

          I don't see the behavior you refer to with the following example, which has a file input field, a text input field, a native HTML submit button and a YUI button labeled "Submit", which invokes Dialog's submit method:

          http://yuiblog.com/sandbox/yui/v260/examples/container/dlgUpload.html

          Hitting enter when the text input field has focus (which will result in a form submission on most browsers, for forms containing only 1 text input field), invokes the Upload callback handler. Clicking the native submit button, or the Dialog's submit button do the same.

          Dialog has code which will listen for anything causing a native form submission (such as hitting enter, or clicking a native HTML submit button) and route the form submission through it's configured postmethod (async XHR submission in the above case).

          If you can post a test page, we can take a look at it.

          Regards,
          Satyen

          ________________________________________
          From: ydn-javascript@yahoogroups.com [mailto:ydn-javascript@yahoogroups.com] On Behalf Of Hans Zaunere
          Sent: Saturday, January 31, 2009 10:26 AM
          To: ydn-javascript@yahoogroups.com
          Subject: [ydn-javascript] Dialog: Submit vs Upload and Hitting Enter

          Hello,

          It appears that there is different behavior between pressing enter and
          clicking submit for a Dialog based form. It's most notable when there's a
          file input.

          For example, when a user actually clicks Submit, both the success and upload
          callbacks are called. When a user simple hits enter, only the upload
          callback is called.

          Is there a way to change this behavior so that it's more reliable. Or at a
          minimum a way to know if the success callback has fired, so that code in
          both places isn't executed twice.

          Thanks.

          ---
          Hans Zaunere / Managing Member / New York PHP
          www.nyphp.org / www.nyphp.com
        Your message has been successfully submitted and would be delivered to recipients shortly.