From fc4d9afd31b0b5ff4d692573b1aa666d88efd7b3 Mon Sep 17 00:00:00 2001 From: Youmin Ha Date: Tue, 15 Jan 2013 15:06:27 +0900 Subject: [PATCH] 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 --- .../virtuallist/js/jquery.mobile.tizen.virtuallistview.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) 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 ) { -- 2.7.4