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

    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 - Tools Team arthurakay's Avatar
    Join Date
    Sep 2008
    Location
    Antioch, IL
    Posts
    1,473
    Vote Rating
    69
    Answers
    85
    arthurakay is a glorious beacon of light arthurakay is a glorious beacon of light arthurakay is a glorious beacon of light arthurakay is a glorious beacon of light arthurakay is a glorious beacon of light

      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.

Thread Participants: 1

Tags for this Thread