最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - "swipe back" in ion-item after click on ion-option-button - Stack Overflow

matteradmin1PV0评论

in an Ionic project I made a ion-list ion-items and these ion-option-buttons:

<ion-list>
     <ion-item class="item " ng-repeat="exercise in exercises" on-double-tap="sendToChangeExercise">

            <p><h2>{{exercise.exerciseName}}</h2></p>

            <p ng-repeat="(parameter, value) in exercise.parameters">
             {{parameter}}: {{value}} <span ng-if="exercise.trainingData[parameter].length > 0 "><b><i>Eintrag im Trainingtagebuch: {{exercise.trainingData[parameter]}}</i></b></span>
            </p>
       <ion-option-button class="button button-calm"  ng-click="openModal(exercise.exerciseID)"> Info </ion-option-button>
       <ion-option-button class="button button-energized"  ng-click="openModal(exercise.exerciseID)"> Ändern </ion-option-button>
       
    <ion-option-button class="button button-balanced"  ng-click="didExercise(exercise.exerciseID)" ng-if="!exercise.done"> Done </ion-option-button>
      </ion-item>
</ion-list>

Let's say I swipe left on an item. Then the buttons appear. I click on a button and it does what it's supposed to do. But the ion-item still is in this "swipe left" state. You know what I mean? Now I have to swipe right so that the buttons disappear. Is there anything so that I could automatically let the buttons disappear at the end of the JS functions?

Thanks for help

in an Ionic project I made a ion-list ion-items and these ion-option-buttons:

<ion-list>
     <ion-item class="item " ng-repeat="exercise in exercises" on-double-tap="sendToChangeExercise">

            <p><h2>{{exercise.exerciseName}}</h2></p>

            <p ng-repeat="(parameter, value) in exercise.parameters">
             {{parameter}}: {{value}} <span ng-if="exercise.trainingData[parameter].length > 0 "><b><i>Eintrag im Trainingtagebuch: {{exercise.trainingData[parameter]}}</i></b></span>
            </p>
       <ion-option-button class="button button-calm"  ng-click="openModal(exercise.exerciseID)"> Info </ion-option-button>
       <ion-option-button class="button button-energized"  ng-click="openModal(exercise.exerciseID)"> Ändern </ion-option-button>
       
    <ion-option-button class="button button-balanced"  ng-click="didExercise(exercise.exerciseID)" ng-if="!exercise.done"> Done </ion-option-button>
      </ion-item>
</ion-list>

Let's say I swipe left on an item. Then the buttons appear. I click on a button and it does what it's supposed to do. But the ion-item still is in this "swipe left" state. You know what I mean? Now I have to swipe right so that the buttons disappear. Is there anything so that I could automatically let the buttons disappear at the end of the JS functions?

Thanks for help

Share Improve this question asked Oct 10, 2015 at 15:43 user2529173user2529173 1,9246 gold badges30 silver badges45 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 13

Or you could just close all option buttons at the end of your function:

$ionicListDelegate.closeOptionButtons();

You still have to inject $ionicListDelegate into your controller but you don't have to add any handlers.

You have to inject $ionicListDelegate into your controller and call its method closeOptionButtons().

Add to your ion-list attribue delegate-handle. Set its value to, for example, "exercise-list". Add this statement to your click handlers:

$ionicListDelegate.$getByHandle('exercise-list').closeOptionButtons();
Post a comment

comment list (0)

  1. No comments so far