From: Youmin Ha Date: Tue, 15 Jan 2013 06:06:27 +0000 (+0900) Subject: virtuallist: fix unique listitem ID bug X-Git-Tag: accepted/tizen_2.1/20130425.023924~7^2~230 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fc4d9afd31b0b5ff4d692573b1aa666d88efd7b3;p=platform%2Fframework%2Fweb%2Fweb-ui-fw.git virtuallist: fix unique listitem ID bug Each
  • element has its own id, but its format is quite simple, like 'li_'. This id can be duplicated when 2 or more virtuallist widget are used together. Added virtuallist element's id as the prefix of IDs of each li element. Change-Id: I94292be2011327ba626407780ffa287d28367ccb --- diff --git a/src/widgets/virtuallist/js/jquery.mobile.tizen.virtuallistview.js b/src/widgets/virtuallist/js/jquery.mobile.tizen.virtuallistview.js index 8be7b28..8c8d1fe 100755 --- a/src/widgets/virtuallist/js/jquery.mobile.tizen.virtuallistview.js +++ b/src/widgets/virtuallist/js/jquery.mobile.tizen.virtuallistview.js @@ -172,7 +172,7 @@ for ( i = 0; i < lastIndex; i++ ) { htmlData = myTemplate.tmpl( this._itemData( i ) ); - $( o.id ).append( $( htmlData ).attr( 'id', 'li_' + i ) ); + $( o.id ).append( $( htmlData ).attr( 'id', o.itemIDPrefix + i ) ); } /* After push data, re-style virtuallist widget */ @@ -295,7 +295,7 @@ break; } - cur_item = $( '#li_' + ( v_firstIndex + i ) ); + cur_item = $( '#' + o.itemIDPrefix + ( v_firstIndex + i ) ); if ( cur_item ) { /* Make New
  • element from template. */ @@ -309,7 +309,7 @@ htmlData.remove(); /* Set New Position */ - ( cur_item ).css( 'top', t._title_h + t._line_h * ( v_lastIndex + 1 + i ) ).attr( 'id', 'li_' + ( v_lastIndex + 1 + i ) ); + ( cur_item ).css( 'top', t._title_h + t._line_h * ( v_lastIndex + 1 + i ) ).attr( 'id', o.itemIDPrefix + ( v_lastIndex + 1 + i ) ); } else { break; @@ -328,7 +328,7 @@ } for ( i = 0; i < num; i++ ) { - cur_item = $( '#li_' + ( v_lastIndex - i ) ); + cur_item = $( '#' + o.itemIDPrefix + ( v_lastIndex - i ) ); if ( cur_item ) { if ( v_firstIndex - 1 - i < 0 ) { @@ -346,7 +346,7 @@ htmlData.remove(); /* Set New Position */ - $( cur_item ).css( 'top', t._title_h + t._line_h * ( v_firstIndex - 1 - i ) ).attr( 'id', 'li_' + ( v_firstIndex - 1 - i ) ); + $( cur_item ).css( 'top', t._title_h + t._line_h * ( v_firstIndex - 1 - i ) ).attr( 'id', o.itemIDPrefix + ( v_firstIndex - 1 - i ) ); } else { break; @@ -528,6 +528,7 @@ return orig + " ui-listview ui-virtual-list-container" + ( t.options.inset ? " ui-listview-inset ui-corner-all ui-shadow " : "" ); }); + o.itemIDPrefix = $el.attr( "id" ) + '_'; o.id = "#" + $el.attr( "id" ); $( o.id ).bind( "pagehide", function ( e ) {