1. #1
    Ext User
    Join Date
    Mar 2007
    Posts
    47
    Vote Rating
    0
    cwells is on a distinguished road

      0  

    Default Unanswered: How to get element from inside event handler

    Unanswered: How to get element from inside event handler


    I want to add a class to an element that has been clicked on:

    Code:
                   Ext.select ("div#topmenu ul li a").on ("click", (
                        function (e, t, o) {
                            e.stopEvent();
                            Ext.get ("middle").load ({
                                url: this,
                                scripts: true
                            });
                            Ext.select ("a.active").removeClass ("active");
                            t.addClass ("active");   // ERROR
                        }
                    ));
    Everything works up to the last line, where t.addClass() gives me the following error:

    Code:
    Uncaught TypeError: Object #<an HTMLElement> has no method 'addClass'
    I am unable to locate any documentation on "HTMLElement", which I assume is distinct from Ext.Element.

    In any case, how can I get add a class to this element?

  2. #2
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,251
    Answers
    1
    Vote Rating
    73
    Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold

      0  

    Default


    It's:
    Code:
    Ext.fly(t).addClass('active');

  3. #3
    Ext User
    Join Date
    Mar 2007
    Posts
    47
    Vote Rating
    0
    cwells is on a distinguished road

      0  

    Default


    Hrm, still doesn't work (although no errors now). Here's the complete code:

    Code:
             Ext.onReady ( function () {
                    Ext.BLANK_IMAGE_URL = "/js/extjs/resources/images/default/s.gif";
    
                    Ext.select ("div#topmenu ul li a").on ("click", (
                        function (e, t, o) {
                            e.stopEvent();
                            Ext.get ("middle").load ({
                                url: this,
                                scripts: true
                            });
                            Ext.select ("a.active").removeClass ("active");
                            Ext.fly (t).addClass ("active");
                        }
                    ));
                });
    This isn't a huge deal for me as the jQuery code is working fine (I was just hoping to reduce my dependencies a bit), but if it *should* work, then consider this a bug report ;-)

  4. #4
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,251
    Answers
    1
    Vote Rating
    73
    Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold Condor is a splendid one to behold

      0  

    Default


    I would use:
    Code:
    Ext.onReady(function () {
      Ext.get('topmenu').on('click', function(e){
        Ext.get('middle').load({
          url: e.getTarget().href,
          scripts: true
        });
        Ext.select('#topmenu a.active').removeClass('active');
        Ext.fly(e.getTarget()).addClass('active');
      }, null, {delegate: 'a', stopEvent: true});
    });

Similar Threads

  1. Viewport inside form element, insted of body element
    By ncardeli in forum Ext 2.x: Help & Discussion
    Replies: 17
    Last Post: 19 Mar 2010, 7:11 PM
  2. Replies: 6
    Last Post: 18 Jul 2009, 12:30 PM
  3. Simple Event Handler for an HTML element
    By databass in forum Ext GWT: Discussion
    Replies: 2
    Last Post: 9 Jun 2009, 1:36 PM
  4. XTYPE Event Handler embedded inside a panel
    By anshubansal2000 in forum Ext 2.x: Help & Discussion
    Replies: 4
    Last Post: 19 Jan 2009, 2:59 PM
  5. is there EXT event and event handler at the page close
    By mxu in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 22 Jan 2008, 2:07 PM

Thread Participants: 1

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar