1. #1
    Sencha Premium Member
    Join Date
    Mar 2012
    Posts
    36
    Vote Rating
    1
    Matt_d is on a distinguished road

      0  

    Default Unanswered: itemtap event not passing htmlelement parameter in Touch 2.1.1

    Unanswered: itemtap event not passing htmlelement parameter in Touch 2.1.1


    I'm trying to get the row of a list view to expand when it's tapped to display extra rows of text. It was working in Sencha Touch 1.9.0, but since upgrading to 2.1.1 no longer works.

    I've setup the itemtap event to pass control to my onPhraseItemTap function shown below:

    Code:
    onPhraseItemTap: function(view, index, htmlElement, e, opts) {      
            // This is the line thats causing the error
            var els = htmlElement.select('div[class=visible]');
            els.replaceCls('visible', 'hidden');   
            var el = htmlElement.down('div[class=hidden]');
            el.replaceCls('hidden', 'visible');
            el.show(true); // show with animation
    }
    The error I am getting is:
    Uncaught TypeError: Object [object Object] has not method 'select'

    and the line which is causing the error is the first one in the function ie.
    Code:
    var els = htmlElement.select('div[class=visible]');
    The problem seems to be that the htmlElement parameter is no longer being passed in properly, so if I add this code to the first line of the function:
    Code:
    console.log('htmlElement = ' + htmlElement.getHtml() );
    it displays 'null'. My code used to work before I upgraded Sencha Touch. Has anyone else encountered this problem or can suggest a solution?

    Matt.

  2. #2
    Sencha Premium Member
    Join Date
    Mar 2012
    Posts
    36
    Vote Rating
    1
    Matt_d is on a distinguished road

      0  

    Default list view bug

    list view bug


    I'm guessing this is a Sencha bug caused by the recent changes to the list view component. I mean it was working before, it's not not now.

    When I do a getXtypes() on this parameter it tells me its a component/container/dataitem/listitem which seems to suggest the list is thinking its a dataview not a listview, and is returning an Ext.dataview.component.DataItem instead of an Ext.Element like it should???

  3. #3
    Sencha User
    Join Date
    Dec 2012
    Posts
    32
    Answers
    2
    Vote Rating
    3
    alanthales is on a distinguished road

      0  

    Default


    the "element" in question, i guess be a http://docs.sencha.com/touch/2-1/#!/...onent.DataItem.

  4. #4
    Sencha Premium Member
    Join Date
    Mar 2012
    Posts
    36
    Vote Rating
    1
    Matt_d is on a distinguished road

      0  

    Default Workaround

    Workaround


    OK, I've found a workaround. Instead of using the target parameter for the itemtap event (which now returns null - a great new undocumented feature of Sencha Touch 2.1.1!!!) I now use the event object (e) paramater ie. Ext.get( e.getTarget() )

    So my function to expand the list row now looks like this:
    Code:
    onPhraseItemTap: function(view, index, target, record, e) {
            this.setPhraseTapped(index); // remember index for later
            
            // Hide last row tapped
             if (this.getLastRowTapped() ) {
                 var lrt = this.getLastRowTapped();
                 lrt.replaceCls('showit', 'hideit');
             }
             
             // Show this row 
            var els = Ext.get( e.getTarget() ); // *** THIS IS THE WAY OF GETTING THE HTML ***
            var el = els.down('div[class=hideit]');
            el.replaceCls('hideit', 'showit');
            el.show(true); // show with animation
    
            // Remember this row so we can hide it next time
            this.setLastRowTapped(el);
        },
    The only other problem is that the expanded list row doesn't display properly anymore, but I've opened another thread for that here: http://www.sencha.com/forum/showthre...g-rows-in-list

    Argh!!! 2 days wasted and counting...

Thread Participants: 1