Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
756 views
in Technique[技术] by (71.8m points)

knockout.js - Are there any knockoutjs page/routing frameworks?

Coming from asp.net MVC 3. In MVC4 they introduced WebAPI's. It would be nice to be able to do all view/routes code in javascript and just rely on MVC for API. Heck it's really cool that webapi's can be run independent of IIS!

That being said:

Are there any page frameworks that can leverage KnockoutJS which are similar to my mock-up below:

Framework.RegisterRoutes(..,mainViewModel);//sets the CurrentViewModel?

Each route being a separate file of a viewModel, and a view to be injected into the master view

var mainviewModel= function(){
   var self = this;
   self.CurrentViewModel = ko.observable();
   ...
   return self;
}

<div id="mainPageContent" data-bind:'html:CurrentViewModel.Render'>
</div>

I know that a lot of this can be achieved by self, but not sure how to achieve the register routes/ loading separate files

I feel like knockoutjs's main strengths is the ability to not intrude into the way you code js (ie build an object/framework how you want so long as the interacting objects are observable)

question from:https://stackoverflow.com/questions/9705078/are-there-any-knockoutjs-page-routing-frameworks

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Pager.js is a URL routing framework built specifically for use with Knockout.js. Make sure you go through the entire Demo to see its full power and flexibility. IMHO, it far exceeds PathJS and Sammy.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...