"Reset" list item after clicking an action


#1

I have a simple list with itemOptions defined for the items. Looks something like this:

 <list animation="slide-in-up" option-buttons="itemButtons">
      <item item="key" href="#/w/{{workoutId}}/e/{{key}}"
        ng-repeat="(key, exercise) in workout.exercises">
        <span class="name">
          {{ exercise.name }}
        </span>
        <span class="numberOf" ng-pluralize count="countSets(exercise.sets)"
          when="{'0': 'No sets', 'one': '1 set', 'other': '{} sets'}"></span>
      </item>
    </list>
$scope.itemButtons = [
  {
    text: 'Rename',
    type: 'button-royal',
    onTap: function(exercise, button) {
      var newExerciseName = prompt("Rename exercise:", "");
      if (newExerciseName) {
        $scope.workout.exercises[exercise].name = newExerciseName;
        $scope.workout.$save();
        // or something, to close the modal
        return true;
      }
    }
  },
  {
    text: 'Delete',
    type: 'button-assertive',
    onTap: function(exercise, button) {
      delete $scope.workout.exercises[exercise];
      $scope.workout.$save();
    }
  }
]

Ideally what I’m looking to do is “slide” the list options back after a successful “Rename” action. Delete doesn’t have this issue, because the item is simply gone from the list. Is there a programmatic way to slide the menu back?


#2

+1 on this.

I have a situation where a hidden item button triggers a destructive action, and I want to show a confirmation pop-up. Canceling the confirmation would ideally slide the list item closed.

A naïve glance through the code (v0.9.27) suggests this doesn’t exist, but it would be really helpful to have a call that can slide the item back to its normal state.


#3

FYI : A very soon to be released new nightly feature has this :

$ionicListDelegate.closeOptionButtons()