1. #1
    Sencha User
    Join Date
    Jun 2011
    Posts
    71
    Vote Rating
    2
    DavidSSL is on a distinguished road

      0  

    Default Answered: Prevent default button action for HTML button

    Answered: Prevent default button action for HTML button


    I would like to know how to prevent the default action for an HTML button click event.
    My code is as follows:
    Code:
    Ext.get('copyShippingToBilling').on('click', function () {
     // Do something
     // Prevent/cancel click event
    });
    I debugged the event handler, and I saw that the Ext.get('copyShippingToBilling') was returning Ext.util.Animate which doesn't have a preventDefault() method.

    So my questions are:
    1. Why am I getting an Ext.util.Animate returned? I was expecting a Ext.button.Button to be returned.
    2. How do I prevent the default behaviour of the button click?

  2. Ext.get() returns an Ext.Element(). Your button is an HTML DOM element, so it will never reference anything related to an ExtJS button component. Very different things.

    look at the API docs for the "click" event on Ext.Element. The first argument is the event object you want... it should have the preventDefault() method.

  3. #2
    Sencha - Services Team arthurakay's Avatar
    Join Date
    Sep 2008
    Location
    Antioch, IL
    Posts
    1,375
    Vote Rating
    37
    Answers
    61
    arthurakay is a jewel in the rough arthurakay is a jewel in the rough arthurakay is a jewel in the rough arthurakay is a jewel in the rough

      0  

    Default


    Ext.get() returns an Ext.Element(). Your button is an HTML DOM element, so it will never reference anything related to an ExtJS button component. Very different things.

    look at the API docs for the "click" event on Ext.Element. The first argument is the event object you want... it should have the preventDefault() method.
    Arthur Kay
    Developer Relations Manager, Sencha Inc.

    Twitter | Sencha Chicago User Group

Thread Participants: 1

Tags for this Thread