When I click on one of the xeditable fields in my form which is populated by ng-repeat
, the form scrolls to the top.
<form editable-form name="myxedit">
<fieldset ng-repeat="shop in myModel.shops track by $index">
<h2>Map Test # {{$index + 1}}</h2>
<div class="col-md-6 pac-card" id="pac-card">
<input id="pac-input-{{$index}}" title="Search" type="text" ng-change="cityCode($index)" ng-model="shop.placeName" />
<div>city is: {{shop.city}}</div>
<div>country is: {{shop.country}}</div>
</div>
<div id="map_canvas-{{$index}}" style="height: 200px;width: 200px;"></div>
<div class="form-group">
<input id="radio-{{$index}}" type="checkbox" ng-model="shop.isFirst" name="firstShop" style="-webkit-appearance: radio;-moz-appearance: radio;-ms-appearance: radio;" ng-change="firstShopChange($index)">
<label for="radio-{{$index}}">First Shop</label>
</div>
<div class="col-md-12">
<div class="form-group" ng-if="myModel.shops.length > 1">
<span class="btn btn-danger pull-right" ng-click="removeShop($index)">Remove Shop</span>
</div>
</div>
<div>
<span e-name="erer" class="editable-click" ng-click="$form.$show()" ng-disabled="myxedit.$waiting" e-ng-blur="$form.$hide()" href="#" editable-text="shop.address">
{{ shop.address || 'empty' }}
</span>
<span ng-show="myxedit.$visible">
<button type="submit" class="btn btn-primary" ng-disabled="myxedit.$waiting">
<span class="glyphicon glyphicon-ok"></span>
</button>
<button type="button" class="btn btn-default" ng-disabled="myxedit.$waiting" ng-click="myxedit.$cancel()">
<span class="glyphicon glyphicon-remove"></span>
</button>
</span>
</div>
</fieldset>
</form>
I have only one xeditable field in every ng-repeat.
How can I stop it from scrolling to the top?
As you can see that I am tracking the ng-repeat by index, let's say I click on xeditable field in the third fieldset
that is repeated by ng-repeat, the form scrolls to top to the xeditable in the first fieldset.
update:
here is the plunker.
https://plnkr.co/edit/y8UHwTHTxtxvQYSWICoh?p=preview
this strange behaviour is visible if you add more shops, and then click on the xeditable field in the last shop, and the form will scroll to the top.