I’m using tabset directive of angular js and using twitter bootstrap slider in tab,
My slidestop event is not calling but it’s working well outside tab.
I know that tabset directive have its own scope , but dont know solution of following problem:-
<tabset class="tab-container">
<tab heading="tab1">
<div class="form-group">
<label>any Level</label>
<div class="input-group w-md">
<input id="slider" ui-jq="slider" ui-options="{min: 0,max: 10,step: 1,value: {{any_level}}}"
class="slider slider-horizontal form-control" type="text"
ng-model="any_level"> {{any_level}}
</div>
</div>
</tab>
</tabset>
controller code
......
angular.element("#slider").on('slideStop', function(data){
alert('asdasd');
})
problem is – alert is not coming when slider inside tab,alert is comming when slider outside tab
i am using this slider
Thanks
3
Answers
Just don’t use
angular.element
in an angular app.EDIT : This isn’t really working with ui-slider. Till ui-slider is work in progress i just woudn’t use it.
Add this to your input :
And this to your controller :
What wasn’t working ? In most of the case an
angular.element
will try to bind your even to the element too early. Your DOM “#slider” element isn’t probably loaded when your try to bind.EDIT An alternative :
First, after paying more attention i wouldn’t recommend this slider at all.
This is actually a work in progress and isn’t really reliable.
I made you an exemple of a html slider with binding in this plunker
You slider looks like this :
This will update the model each time the value will not change for 100miliseconds. You need this to avoid firing too much ng-change function.
In your javascript you just need to declare your function
I know this is not a solution but an alternative. It’s not sexy as the other slider, but at least it works.
Hope it helped you.
The slider you are using has an example demonstrating how to do this. Take a look at box “12” on this page: http://angular-ui.github.io/ui-slider/demo/demo.html
In your controller you can add the following:
And your HTML you must reference
slider.options
so your callback is fired:i have solved using ui-event directive to fire slidestop event
Html Code
Controller Code