[CLOSED] Click event launched several times

  1. #1

    [CLOSED] Click event launched several times

    Hi, I have a web page where you fill information, and at the bottom a button to save this info. After the database saves this info succesfully (or in case that any error occurs), an alert is shown to the user.

    I have discovered that, between the button click and the alert show, the user can click several times more the save button. These new clicks causes a new save on the database. I have tried locking the button (disabling after the click and enabling it after the message show), but this implies to add new code to a lot of places and I'm searching for a "cleaner" solution.

    Can you give me any idea to solve this?

    Thank you in advance
    Last edited by Daniil; Dec 29, 2011 at 1:37 PM. Reason: [CLOSED]
  2. #2
    Hi,

    I can't see any better solution than disabling/enabling a button.

    Could you clarify why does this solution cause the problem below?
    this implies to add new code to a lot of places
    As far as I can understand you use a Click DirectEvent and should:

    1. Disable a button within a DirectEvent's Before handler.
    Before="this.disable()"
    and

    2. Enable a button within DirectEvent's Success and Failure handler.
    Success="this.enable();"
    Failure="this.enable();"
    Or, certainly, you can enable a button when any changes appear to save.
  3. #3
    Quote Originally Posted by Daniil View Post
    2. Enable a button within DirectEvent's Success and Failure handler.
    Success="this.enable();"
    Failure="this.enable();"
    I forgot about DirectEvent's Complete handler which can substitute the two ones above.
    Complete="this.enable();"
  4. #4
    Ok, thank you. However your solution can't be applied directly to my code because I'm using a listener instead of a DirectEvent. I attach you the code:

    var saveClick= function() {
     //Validation code in javascript
            Ext.net.DirectMethods.Save() ; --this invocation can be long lasting.
     //More javascript code
    }
    How can I simulate the Complete and Before events that you have suggested on this case?

    Thank you Daniil.
  5. #5
    In DirectMethod case it should look this way:

    Example
    Ext.net.DirectMethods.Save({
        before : function () {
            alert('before');
        },
        complete : function () {
            alert('complete');
        }
    });
    See also
    https://examples1.ext.net/#/Events/D...hods/Overview/

Similar Threads

  1. [CLOSED] question about click event
    By rosua in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Mar 22, 2012, 7:07 AM
  2. [CLOSED] FieldLabel click event
    By amitpareek in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Oct 13, 2011, 7:03 PM
  3. Change Event then Click event : issue
    By jeybonnet in forum 1.x Help
    Replies: 2
    Last Post: May 28, 2010, 1:19 PM
  4. Replies: 4
    Last Post: Jan 28, 2009, 12:28 PM
  5. [CLOSED] gridpanel click Event
    By speedstepmem3 in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jan 07, 2009, 11:30 AM

Tags for this Thread

Posting Permissions