0

I have this dropdown on knockoutjs

     <p>
        text
        <select data-bind="options: optDiv, 
        value: ligaSelec,
        optionsCaption: 'Divison' "></select>
        
    </p>

but a dont know how to trigger a function each time a change the dropdown

crearTabla1: function(option, item){
        do stuff
      },
VLAZ
  • 26,331
  • 9
  • 49
  • 67
  • Perhaps this question helps you: https://stackoverflow.com/questions/11078016/change-event-on-select-with-knockout-binding-how-can-i-know-if-it-is-a-real-cha. – Jose Luis Jun 25 '21 at 18:32
  • [This answer](https://stackoverflow.com/a/43158167/3297291) might help – user3297291 Jun 29 '21 at 10:25

1 Answers1

0
<p>
  text
  <select data-bind="options: optDiv, 
        value: ligaSelec,
        optionsCaption: 'Divison',
        event:{ change: $root.DivisionChanged}"></select>

</p>

var vm = {
  optDiv: ['Div1', 'Div2'],
  DivisionChanged: function() {
    alert('Div changed');
  },
  ligaSelec: ko.observable()
};

ko.applyBindings(vm);



https://jsfiddle.net/1dtp0bc4/
Homer
  • 7,594
  • 14
  • 69
  • 109