I have a list of div elements, when the customer selected an element, the detail view appear. After the back, i want to target my list on selected element.
<div id="patient{{patient.PId}}" class="div-patient" ng-repeat="patient in patients">
<p>{{patient.name}}</p>
</div>
I have tested many code to scroll on a selected patient:
$(window).scrollTop($("#patient"+$rootScope.selectedPatient).offset().top);
// or
$("html, body").animate({ scrollTop:angular.element("#patient"+$rootScope.selectedPatient).prop( 'offsetTop' ) });
//or
$(window).scrollTop(angular.element("#patient"+$rootScope.selectedPatient).prop( 'offsetTop' ));
The css div-patient:
position: absolute;
height: 330px;
margin-bottom: 30px;
top: {{360*fixTopCell($index)}}px;
But
$("#patient"+$rootScope.selectedPatient).offset().top
and
angular.element("#patient"+$rootScope.selectedPatient).prop( 'offsetTop' )
Return 0 all the time.
It works when I use a table tag instead of a div.
I see that the function scrollTop is not available in Android 4.X. Are there others solutions to target the element selected after a back on list?