Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Express and Backbone : best practices for view ?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  11 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
isil  
View profile  
 More options Jun 4 2012, 4:51 am
From: isil <isilga...@gmail.com>
Date: Mon, 4 Jun 2012 01:51:40 -0700 (PDT)
Local: Mon, Jun 4 2012 4:51 am
Subject: Express and Backbone : best practices for view ?
Hi,

What is the best practice to use Backbone with Express.js ?
Both rendering views !!
When use Express for rendering view or Backbone ?
I'm lost ....

Thanks for your help.
Best regards.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
John Teague  
View profile   Translate to Translated (View Original)
 More options Jun 6 2012, 3:00 pm
From: John Teague <jctea...@gmail.com>
Date: Wed, 6 Jun 2012 14:00:39 -0500
Local: Wed, Jun 6 2012 3:00 pm
Subject: Re: [Express-js] Express and Backbone : best practices for view ?

While I have yet to apply this directly to jade, but I have used backbone
with other frameworks that used view engines so I don't know why it
wouldn't work.

Personally, I like to have the server render as much of the the view that
is possible at page rendering time.  I'll create the basic html that I know
doesn't change when actions occur on the client.  Then I use client side
templates for dynamic changes on screen.  The downside to this is that
testing your backbone views is much harder, in fact I don't have a
consistent strategy that I'm really happy with yet.

I also render as much data as I can, as an array of objects in the view,
then use the Collection.reset method, so the collections are fully
populated, but doesn't require a second ajax call to get it.

This has worked for me but I'd like to hear how others are doing it as well.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
deitch  
View profile  
 More options Jun 7 2012, 11:56 am
From: deitch <a...@deitcher.net>
Date: Thu, 7 Jun 2012 08:56:47 -0700 (PDT)
Local: Thurs, Jun 7 2012 11:56 am
Subject: Re: Express and Backbone : best practices for view ?
I do almost nothing view-related on the server. The server does the
following:

- respond to REST requests at /api/whatever....
- serve up static resources: my main.html page, CSS, JS, images, etc.

Everything else happens in the browser (which BTW makes moving to a
mobile app relatively trivial).

I have a main.html, partials (each ending in .html) for major sections
of an app, and everything else happens inside the app (Sammy for
routing, Backbone for models/views/collections, jQuery).

For testing the server, it is easy, since it is all REST.

For testing the client, I use zombie (headless browser) + nodeunit
(but you could use vows, expresso, mocha, whatever tickles your
fancy). This gets 96%+ of cases, and allows me to make changes with
confidence. I still need *some* level of manual testing because of
browser-specific issues (IE, anyone?), but speed is dramatically
faster.

On Jun 6, 10:00 pm, John Teague <jctea...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
tjholowaychuk  
View profile  
 More options Jun 7 2012, 1:01 pm
From: tjholowaychuk <tjholoway...@gmail.com>
Date: Thu, 7 Jun 2012 10:01:29 -0700 (PDT)
Local: Thurs, Jun 7 2012 1:01 pm
Subject: Re: Express and Backbone : best practices for view ?
keep in mind to analyse your app on a case per case basis, don't
fall into the trap of "single page apps all the time everywhere is the
best solution!!"
because it's not. Facebook and Twitter have great writeups on these
issues but
it's very much an app-specific problem.

On Jun 4, 1:51 am, isil <isilga...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
deitch  
View profile  
 More options Jun 7 2012, 1:04 pm
From: deitch <a...@deitcher.net>
Date: Thu, 7 Jun 2012 10:04:29 -0700 (PDT)
Local: Thurs, Jun 7 2012 1:04 pm
Subject: Re: Express and Backbone : best practices for view ?
You have links to their write-ups? I would enjoy reading them.

On Jun 7, 8:01 pm, tjholowaychuk <tjholoway...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
mgutz  
View profile  
 More options Jun 8 2012, 12:58 pm
From: mgutz <mario.l.gutier...@gmail.com>
Date: Fri, 8 Jun 2012 09:58:52 -0700 (PDT)
Local: Fri, Jun 8 2012 12:58 pm
Subject: Re: Express and Backbone : best practices for view ?

Use Express to generate the single page app view, not-found, error and any
informational static page. In some cases, you might want to create more
than one app view. For example, an app can be divided into admin and public
and it's a pain trying to do all of that in one Backbone app.

Most hackers try to dynamically fetch data for their Backbone views from
page load. I would advise against that. The issue is a user can be left
viewing a blank page if your data services are too busy. Bootstrap the data
the initial set of data, then fetch as needed. We do something like this:

# app.mustache on server
<html>
  <body>
    <script>
      var bootstrapData = {
         posts: {{{firstPageOfPosts}}}
      };
      $(function() {
         // set the app in motion
         App.run(bootstrapData);
      });
    </script>
  </body>
</html>

App views for the app can be handled by Backbone. The usual practice is to
use inline <script> tags for Backbone view templates. We have a different
approach and precompile all our Backbone templates as Javascript functions
which are then sourced as any other javascript file. You might also want to
start with a good foundation such as Backbone.Marionette which has some
best practices built-in.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dan Stroot  
View profile  
 More options Jun 8 2012, 11:24 pm
From: Dan Stroot <dan.str...@gmail.com>
Date: Fri, 8 Jun 2012 20:24:08 -0700 (PDT)
Local: Fri, Jun 8 2012 11:24 pm
Subject: Re: Express and Backbone : best practices for view ?

Search github for "Bookmarkly" - Express serves the app and REST API,  App
itself is all Backbone.  Great way to learn the difference.  

- Dan


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bobby Chambers  
View profile  
 More options Jun 9 2012, 1:39 pm
From: Bobby Chambers <bobby.chamber...@gmail.com>
Date: Sat, 9 Jun 2012 13:39:21 -0400
Local: Sat, Jun 9 2012 1:39 pm
Subject: Re: [Express-js] Re: Express and Backbone : best practices for view ?

@deitch: I am interested in why u are using sammyjs for routing and not
backbone. If u get a chance would u mind explaining?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
deitch  
View profile  
 More options Jun 9 2012, 1:55 pm
From: deitch <a...@deitcher.net>
Date: Sat, 9 Jun 2012 10:55:48 -0700 (PDT)
Local: Sat, Jun 9 2012 1:55 pm
Subject: Re: Express and Backbone : best practices for view ?
Sure. In principle, it is because I like:
1) around/before/after for routes
2) using the actual function rather than the name of the function in a
string (always found that messy 'bout backbone)
3) control by verb

My routes look a lot like express:

app.get('#/post/:id/edit",showEditPost);
app.post('#/post/:id/edit",submitPostChanges);

Of course, to be really honest, also because I have been using Sammy
since well before backbone. :-)

On Jun 9, 8:39 pm, Bobby Chambers <bobby.chamber...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bobby Chambers  
View profile  
 More options Jun 9 2012, 2:23 pm
From: Bobby Chambers <bobby.chamber...@gmail.com>
Date: Sat, 9 Jun 2012 14:23:00 -0400
Subject: Re: [Express-js] Re: Express and Backbone : best practices for view ?

@deitch: thank u for replying. Those are exactly the reasons I am not in
love with the backbone router. Sweet, now I can try something else. Thanks
On Jun 9, 2012 1:55 PM, "deitch" <a...@deitcher.net> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
deitch  
View profile  
 More options Jun 16 2012, 2:08 pm
From: deitch <a...@deitcher.net>
Date: Sat, 16 Jun 2012 11:08:38 -0700 (PDT)
Local: Sat, Jun 16 2012 2:08 pm
Subject: Re: Express and Backbone : best practices for view ?

Interesting. I tend to break into multiple files to keep my server.js more
readable, and I used to do what he does for bundle() to load up scripts,
although I have tried requirejs lately on the client side and find it much
cleaner.

I also try to keep sql out of the routes, and do something much more
mvc-like on the express side.

Still, good reference point. Thanks for posting.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »