无法在durandal绑定功能点击

时间:2014-02-20 15:23:55

标签: durandal

无法在durandal

中绑定点击功能

视图模型:

define(function (require) {
    var system = require('durandal/system');
    var app = require('durandal/app');
    var router = require('durandal/plugins/router');
return {

        activate: function () {

        },
 addIdea: function () {
        debugger;
    }
};

});

视图上的按钮:

<input type="button" data-bind='click:addIdea' value="Add" />

欢迎任何建议!

1 个答案:

答案 0 :(得分:0)

它对我有用:

 define(['repositories/vmRepository', 'durandal/app', 'durandal/plugins/router'], function (vmRepository, app, router) {

  idea:ko.validatedObservable({
          ...
        }),
 activate: function () {
        },

   addIdea: function () {
        }
    }
return vm;

查看:

<div data-bind="with: idea">
...
  <input type="button" data-bind='click: $parent.addIdea' value="Add" />
</div>