Question

In ionic we have slideBox.I want to disable swipe .I want it to slide on button click.How can i do it?

I have tried $ionicSlideBoxDelegate.enableSlide(false) in my controller but it is not working.

According to this link http://forum.ionicframework.com/t/ionicslideboxdelegate-disable-all-swiping/6391 i have to disable in the scope of the slidebox but how to access the scope of the element and apply it?

Was it helpful?

Solution

The proper place to do it is in ng-init

<ion-slide-box ng-init="lockSlide()">

and have the respective function in your controller

.controller('sliders', function($scope, $ionicSlideBoxDelegate) {
    $scope.lockSlide = function () {
        $ionicSlideBoxDelegate.enableSlide( false );
    }
}

OTHER TIPS

In your html file put active-slide="slidestop($index)"

<ion-slide-box active-slide="slidestop($index)">
</ion-slide-box>

And in Controller class that function "slidestop"

$scope.slidestop = function(index) {
    $ionicSlideBoxDelegate.enableSlide(false);
}

Your issue is probably that the slidebox needs to be rendered before you can disable sliding. So in your controller, use a timeout:

$timeout(function(){
    $ionicSlideBoxDelegate.enableSlide(0);
},0);

In your html add

<ion-slide-box active-slide="slidestop" does-continue="false">

And in your controller add

$timeout(function(){
$ionicSlideBoxDelegate.enableSlide(false);
},0);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top