0

I'm newbie on using SpineJS and having happy time with it.

And, when I finished contact examples and saw some other components in SpineJS,

I realized there's no example about Web Site(which has many html pages).

It seems like SpineJS is not proper framework for web site design.

(I think this kind of framework is proper for Single Page Application)

I thought like that because I should create 'websocket' object in the first view of my web site.

I cannot keep the 'websocket' object when I leave first view( html page changed.).

I should keep this 'websocket' for whole time until user logs out.

Is it right? or are there ways that I can create multi view web site?

(AngularJS framework support this with $route service. - it can load html page without reloading whole framework.)

1 Answers1

0

You can certainly implement multi-page websites within a single-page RIA. Ok, that sounds paradoxical. From the server side, it's rendering a single page, serving the source code. But within the client code, the Router object may render the page completely differently based on the route.

Edit / Addition:

Not sure if this is best, but here's how my app loads templates stored in separate html files within the app source code, e.g. myview.template = app.TemplateManager.fetch('grids/item');

  templateManager: {
    JST : {},   // hash table so not to load same template twice

    fetch: function(path) {
      url = "/app/templates" + path + ".html";

      if (!this.JST[path]) {
        $.ajax({ url: url, async: false }).then(function(contents) {
          this.JST[path] = _.template(contents);
        });
      } 

      return this.JST[path];
    }
  });
prototype
  • 7,249
  • 15
  • 60
  • 94
  • Um.. the route in SpineJS catches URL hash changes(and it can change the hash) and then, it will notify with callback about that. In this callback I may render the template I want. But, what I want to know is how to load external html page.(not in the template code in index.html). If I have many pages in my web app then, index.html will be thousand of lines with many templates. – EmbeddedWorker Jan 31 '13 at 04:58
  • Ah, is the issue not so much about Spine.js but rather managing the multitude of templates? My app has dozens of "pages", each of which are rendered within the browser using Spine.js with a different template. Initially, I kept the templates inside `index.html` using ` – prototype Feb 01 '13 at 14:58
  • So, this job is up to users who use SpineJS. But, thank you for your kind answer. I may need a lot of practice to add new functionality what I need on SpineJS. Thanks again. – EmbeddedWorker Feb 05 '13 at 08:19