First steps with Sammy.js

By YopY on Monday 13 June 2011 13:18 - Comments (13)
Category: -, Views: 6.748

Sammy.js is a small, modular front-end Javascript web frontend which helps structure your rich internet applications. In a blogpost I wrote on Xebia NeXt, I share my experiences in using Sammy to create a front-end to my screwing-around project Norum, a forum / message board written in NodeJS. It's also compared to another web application front-end library I've used in a previous project, Backbone.

I'm afraid I can't copy / paste the whole article to this blog - too much formatting involved, I would have to spend an hour or so converting HTML and Gist snippets over to BBCode. So please, if you're interested, go to the source to read the full article. If you're just slightly curious about Sammy, here's the code snippet we develop in the article:


JavaScript:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
(function($) {
  var app = $.sammy('#main', function() {
    this.use('Template');
    this.get('#/', function(context) {
      this.load('thread')
        .then( function(threads) {
          $.each(threads, function(i, thread) {
            context.render('templates/thread.template', {thread : thread})
              .appendTo(context.$element());
          });
        });
    });
  });
  $( function() {
    app.run('#/');
  });
})(jQuery);



About Xebia NeXt

Xebia NeXt is a program within Xebia that offers promising and talented post-graduates a year-long apprenticeship, where they get to spend their time exploring new technologies, participating as apprentices in projects, and gain experience in the real world, far beyond the scope often found in internships. We are currently looking for new apprentices, so if you're interested or wondering what it's all about, send me a Direct Message. No strings attached.