John Washam
John Washam

Reputation: 4103

MVC 4 SPA without JS frameworks?

I spent almost an entire day researching possibilities for using SPA with MVC 4. I came upon template after template and JS framework after framework. People are using Knockout, Backbone.js, Breeze.js, and so many other frameworks. It also seems like a lot of people are using MVVM to display data.

But what I was really looking for was if there is a way to develop an SPA that does not depend on multiple JS frameworks to make it work. Is there some minimal setup that uses the bare minimum of plugins and frameworks to get an SPA working? I noticed we could use just History.js, but then we would need some sort of routing abstraction, correct? So what if we just want to setup simplistic routing (browser history management) and not MVVM? Are there options for doing that?

(please let me know if I can phrase my question better or if I can improve it)

Upvotes: 3

Views: 1531

Answers (1)

Imran Rashid
Imran Rashid

Reputation: 3492

You can configure sammy.js or history.js on page load and load views dynamically...

 sammy.get('#/(.*)', function (context) {
      var url = this.params['splat'];
      $("#main").load(url);
 });

for example if we load localhost:333/Home/ContactUs... It will read the contact us view and load contents dynamically.

Here are other libraries which you can compare if you want to choose a js framework for SPA. I think angular covers all requirement for spa as single library. http://blog.stevensanderson.com/2012/08/01/rich-javascript-applications-the-seven-frameworks-throne-of-js-2012/

Upvotes: 1

Related Questions