[CLOSED] FormPanel: Execute all events on the form before submit it

  1. #1

    [CLOSED] FormPanel: Execute all events on the form before submit it

    Hello,

    I would like to do folowing:

    I define a formPanel wit some controls(textfields etc...) and a button B, whose click event submit the form to the server to be saved.

    The controls on the form have also events which be execute before the form is submitted. For example on blur of the control C do execute the function F.

    I notice that when I enter something in the textField C and click the button B, the submit is done before the function F is called.

    How can I block the submission of the form until all handler of control on the form have been executed? I don't want to delay the submission for a time, because I would want to be sure that all handler are executed and the estimation of this time can be difficult.

    Any idea?

    Romuald.
    Last edited by Daniil; Sep 14, 2010 at 7:56 PM. Reason: [CLOSED]
  2. #2
    Hi,

    Does that Blur event execute client or server side function?
    If it is client side only then you can use small delay because javascript one thread executing language and even small delay guarantees that all client side event handlers will be executed
  3. #3
    Hello,

    I don't only have blur event handler. I also have another event like change etc....

    The blur event executes a client side function. Also the click on the button raises a client side function which in turn submits the form with this code excerpt
    formPanel.form.submit(....)

    I dont really understant what you mean with "javascript one thread executing language and "

    Any idea?

    Romuald.
  4. #4
    Hi,

    I dont really understant what you mean with "javascript one thread executing language and "
    It is mean that there is no parallel code execution in the javascript. It is mean that you can add small delay before submit calling, it ensures that all events handlers (like blur, change) will be finished before submit even if its execution time is greater then delay because submit will not be called while another javascript code executes

    Here is the sample
    <%@ Page Language="C#" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.Net Example</title>
        
        <script type="text/javascript">
            function log(msg){
                Ext.getBody().createChild({
                    tag: "p",
                    html: msg
                });
            }
            
            function submit(formPanel){
                log('Start submitting');
                formPanel.getForm().submit({
                    waitMsg : 'Submiting...',
                    url: 'submitHandler',
                    success : function(){
                        log('End submiting');
                    },
                    
                    failure : function () {
                        log('End submiting');
                    }
                });
            }
        </script>
    </head>
    <body>
            <ext:ResourceManager runat="server" />
            
            <ext:FormPanel ID="FormPanel1" runat="server" Title="Form" Width="400" Height="300">
                 <Items>
                    <ext:TextField runat="server" FieldLabel="Field1">
                        <Listeners>
                            <Change Handler="log('Field1 - Change');" />
                            <Blur Handler="log('Field1 - Blur');" />
                        </Listeners>
                    </ext:TextField>
                    
                    <ext:TextField runat="server" FieldLabel="Field2">
                        <Listeners>
                            <Change Handler="log('Field2 - Change');" />
                            <Blur Handler="log('Field2 - Blur');" />
                        </Listeners>
                    </ext:TextField>
                 </Items>
                 
                 <Buttons>
                    <ext:Button runat="server" Text="Submit">
                        <Listeners>
                            <Click Handler="submit(FormPanel1);" Delay="10" />
                        </Listeners>
                    </ext:Button>
                 </Buttons>
            </ext:FormPanel>
    </body>
    </html>

Similar Threads

  1. [CLOSED] Form Submit
    By IanPearce in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: May 07, 2012, 9:28 AM
  2. How to Submit FormPanel Data
    By abhijit in forum 1.x Help
    Replies: 3
    Last Post: Feb 24, 2012, 7:18 AM
  3. Replies: 1
    Last Post: Aug 02, 2011, 12:59 PM
  4. [CLOSED] Submit gridpanel data in form submit
    By jchau in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Jul 14, 2010, 7:25 PM
  5. [CLOSED] [1.0] Form Submit
    By Timothy in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Feb 17, 2010, 8:02 AM

Posting Permissions