class ViewModel
constructor: ->
$.ajax({url: '#.json', type: 'GET', dataType: 'json'})
.done @buildModel
buildModel: (data) =>
@model = ko.mapping.fromJS(data)
@model.update = =>
delete @model.update
jsonForm = ko.mapping.toJSON(@model)
$.ajax({url: '#.json', data: jsonForm, type: 'PUT', contentType:"application/json; charset=utf-8", dataType: 'json'})
.done @buildModel
ko.applyBindings(@model)
###################################################################
class FormViewModel extends ViewModel
buildModel: =>
super()
如果我这样称呼:
$(document).bind 'pageinit', =>
@form = new ViewModel
一切安好。如果我尝试继承
$(document).bind 'pageinit', =>
@form = new FormViewModel
收到错误:
Uncaught Error: Unable to parse bindings.
Message: ReferenceError: update is not defined;
Bindings value: click: update
为什么 ko.applyBindings 对这种继承不满意?