Results 1 to 4 of 4

Thread: Help With DOM

  1. #1
    Sencha User
    Join Date
    Oct 2010
    Location
    NYC
    Posts
    33

    Question Help With DOM

    Hey I have a list and I want to know if there is a way to check which link in the list was clicked.

    for example
    ul
    -li
    -a#id
    -li
    -a#id
    -img

    I want to be able to check which id was clicked.

    this works
    Code:
    Ext.select("ul li a").on('click', function(t, ref){
         console.log(ref.id);
    });
    but it only works on the link without the image if i click the lick with the image I get the image and not the link id.

    is there a way to only get the links id so i can make a conditional statement?

    thanks for any help.

  2. #2
    Sencha User
    Join Date
    Oct 2010
    Location
    NYC
    Posts
    33

    Default

    No help here? I am having no luck on my own.

  3. #3
    Sencha User Screamy's Avatar
    Join Date
    Jun 2008
    Posts
    244

    Default

    The target of the click is actually the image, so you're going to have to do a little bit of evaluation:

    Code:
    Ext.select("ul li a").on('click', function(t, ref){
      var desiredId = ref.id;
    
      if (ref.parentNode.tagName == 'A') {
        desiredId = ref.parentNode.id;
      }
    
      console.log(desiredId);
    });

  4. #4
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    Inefficient. You should use a single click handler with a delegate, e.g.
    Code:
    Ext.select('ul').on('click', function(e, t) {
      var id = t.id;
      ...
    }, null, {delegate: 'a'});

Similar Threads

  1. [EXT 3.0.0] ct.dom.insertBefore(this.el.dom, position) problem
    By squarefan in forum Ext 3.x: Help & Discussion
    Replies: 5
    Last Post: 17 Aug 2009, 2:42 AM
  2. TabPanel:add DOM to tab using autoTabs; then how to change back to normal DOM?
    By choykawairicky in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 23 Jan 2008, 12:40 AM
  3. el.dom.text vs el.dom.textContent
    By bowa in forum Ext 1.x: Help & Discussion
    Replies: 1
    Last Post: 21 Nov 2007, 3:16 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •