可观察到的变化敲除时的触发功能

时间:2018-06-21 01:50:50

标签: knockout.js

我有一个复选框,我想在选中该功能后立即触发它。我注意到有时使用ko:binding处理程序来处理此问题,但对我来说似乎有点过头了。选中我的复选框后,我将如何触发功能?我想触发名为thealertIwantToSend的函数。见我的小提琴here

var docDefinition = {
  content: [
    {
       table: {
        // headers are automatically repeated if the table spans over multiple pages
        // you can declare how many rows should be treated as headers
        headerRows: 1,
        widths: [ '*', 'auto', 100, '*' ],

        body: [
          [ 'First', 'Second', 'Third', 'The last one' ],
          [ 'Value 1', 'Value 2', 'Value 3', 'Value 4' ],
          [ { text: 'Bold value', bold: true }, 'Val 2', 'Val 3', 'Val 4' ]
        ]
      }
    }
  ]
};

pdfMake.createPdf(docDefinition).print()

1 个答案:

答案 0 :(得分:0)

解决方案是订阅可观察对象,然后启动功能。

self.wantsSpam.subscribe(function(){
self.thealertIwantTosend();
})

如果有人感兴趣,更新的小提琴将是HERE

相关问题