如何将此 javascript 转换为咖啡脚本?
$(function() {
function AppViewModel() {
this.firstName = ko.observable();
}
ko.applyBindings(new AppViewModel());
});
我试过了,但它破坏了 knockoutjs 绑定
jQuery ->
AppViewModel = ->
this.firstName = ko.observable("something")
ko.applyBindings(new AppViewModel())
这是咖啡脚本产生的
(function() {
jQuery(function() {
var ViewModel;
ViewModel = function() {
return this.firstName = ko.observable();
};
return ko.applyBindings(new ViewModel());
});
}).call(this);