ionic-framework: Failed to use delegate-handle for several instances of ion-slide-box
I have 3 ion-slide-box. Everyone has 3 items.
I created two buttons Next and back to simulate sliding by pressing them.
However delegate-handle doesn’t work. I get:
Delegate for handle "slider1" could not find a corresponding element with delegate-handle="slider1"! next() was not called!
Sounds like delegate-handle doesn’t register properly the instance ids.
This is what I have so far:
scope.nextSlider = function(sliderId){
$timeout(function(){
$ionicSlideBoxDelegate.$getByHandle(sliderId).next();
}, 1000);
}
scope.prevSlider = function(sliderId){
$timeout(function(){
$ionicSlideBoxDelegate.$getByHandle(sliderId).previous();
}, 1000);
}
Template
<ion-slide-box delegate-handle="{{sliderId}}"
on-slide-changed="slideHasChanged(index)"
show-pager="false">
<ion-slide ng-repeat="color in colors">
<!-- -->
</ion-slide>
</ion-slide-box>
And this is a DEMO I play with
The issue was posted in Ionic Forum
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Comments: 16 (1 by maintainers)
Commits related to this issue
- fix(slidebox): refactor for performance and stability Closes #2336. Closes #2317. Closes #2290. Closes #2228. Closes #2067. Closes #1890. Closes #1865. Closes #1850. Closes #1755. Closes #1688. Close... — committed to ionic-team/ionic-framework by ajoslin 10 years ago
- fix(slidebox): refactor for performance and stability Closes #2336. Closes #2317. Closes #2290. Closes #2228. Closes #2067. Closes #1890. Closes #1865. Closes #1850. Closes #1755. Closes #1688. Close... — committed to ionic-team/ionic-framework by ajoslin 10 years ago
An universal directive to use random-generated delegate-handle (inspired to @mikesurowiec ) :
}]);
use:
I had a similar problem and asked it in StackOverflow and got a great temporary solution to the problem. See it at StackOverflow. So basically set and get the delegate-handle by id of the container.
Hopefully this can help someone in the future.
Still appears to be messy using 1.0.0-rc.1
danfaber’s comment above was really useful in working out what the problem is, but the find() fn is not totally portable it seems 😦
I just created a very simple service to manage jumping between tabs in my application (which has lots of nested tabs, and breaks quickly using ionic’s built in tab delegate functions).
A horrible solution perhaps … but this is working very reliably for me at the moment, and it bypasses any need to touch the underlying ionic libs. The code below is verbose and non-optimal, but its easy to reason about, and portable.
Usage :
Based on @thepi0 's Link I could solve this problem. For someone who needs help, share code here. You can just put this on your controller. To get dynamically created index of the slide box like with ng-repeat
usage HTML
<div class="list" ng-repeat="myIndex in dynamics> <ion-slide-box delegate-handle="{{myIndex}}">JS
$scope.slideIndex = $scope.getSlideBoxDelegateHandle(myIndex).currentIndex or anymethod;Hello is this issue has been solved?
i still have same problem with generated delegate-handle
this is my code JS Controller
$scope.swapName = "swap00";$scope.ds = function (sN) { $ionicSlideBoxDelegate.$getByHandle(sN).enableSlide(false); };HTML<ion-slide-box show-pager="false" delegate-handle="{{swapName}}" ng-init="ds(swapName)"><ion-slide > 1 </ion-slide><ion-slide > 2 </ion-slide><ion-slide > 3 </ion-slide></ion-slide-box>i get this message: Delegate for handle “swap00” could not find a corresponding element with delegate-handle=“swap00”! enableSlide() was not called! Possible cause: If you are calling enableSlide() immediately, and your element with delegate-handle=“swap00” is a child of your controller, then your element may not be compiled yet. Put a $timeout around your call to enableSlide() and try again.