简体   繁体   中英

Meteor & noUiSlider: how can I listen to events?

I just got the noUiSlider for meteor, but am having problems with listening to events. Here is my code:

Template.templateOne.events({
  'click #slider': function(){
    console.log('event works!');
  }
});

Unfortunately this doesn't work. According to this there is also build in events such as slide. How can I use them in Meteor?

Thanks in advance!

is it mandatory to bind it like this...??

Template.templateOne.events({
  'click #slider': function(){
    console.log('event works!');
  }
});

i think you can do it like this:

 var noui = document.getElementById('#slider');
 noui.noUiSlider.on('slide', function(){
    console.log('i think it will work');
 });

ok then do it like this

Template.templateOne.rendered = function () {
    var slider = document.getElementById('#slider')
    this.slider.noUiSlider({
      start: Session.get("slider"),
      connect: true,
      range: {
        'min': 0,
        'max': 100
      }
    }).on('slide', function (ev, val) {

      console.log('i think it will work');

      Session.set('slider', val);
    }).on('change', function (ev, val) {
      // round off values on 'change' event
      Session.set('slider', [Math.round(val[0]), Math.round(val[1])]);
    });
  };

you can look on this example https://github.com/rcy/meteor-nouislider/blob/master/example/example.js

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM