我正在寻找一个非常简单的示例,显示将Knockback代码连接到通过RESTful服务连接的骨干模型.我正在使用ServiceStack | c #backend.下面的所有链接都太复杂,并且使用localStore而不是通过url的RESTful服务.我也更喜欢在Javascript而不是CoffeeScript中看到示例.
我的示例url类似于localhost/entities,其中命中这将导致RESTful webservice返回所有实体.使用localhost/entity/1命中它将返回ID为1的实体.
_http://kmalakoff.github.com/knockback/index.html
_HTTPS://github.com/kmalakoff/knockback-reference-app/
_HTTPS://github.com/addyosmani/todomvc
以下是第一个链接上的knockback教程的示例:
Models, Collection, ViewModel, and Bindings:
// Generated by CoffeeScript 1.3.3
var model, view_model;
model = new Backbone.Model({
first_name: "Planet",
last_name: "Earth"
});
view_model = kb.viewModel(model);
view_model.full_name = ko.computed((function() {
return "" + (this.first_name()) + " " + (this.last_name());
}), view_model);
ko.applyBindings(view_model, $('#kb_view_model_computed')[0]);
Run Code Online (Sandbox Code Playgroud)
但是没有提到如何将骨干模型连接到RESTful Web服务.
有一些例子说明了如何通过Backbone进行此操作,但我不确定使用Knockback时情况如何变化.
找到以下链接,但没有帮助:
_http://stackoverflow.com/questions/7992431/using-knockoutjs-backbone-together
_http://stackoverflow.com/questions/9704220/is-knockback-js-production-ready
_http://stackoverflow.com/questions/10434203/defining-models-on-server-side-when-using-mvvm-with-knockout-js
提前感谢您提供的任何帮助.顺便说一句,你不希望你得到下划线的超链接...;)