sammy

Sammy is a tiny javascript framework built on top of jQuery, It's RESTful Evented Javascript.

  • 所有者: quirkey/sammy
  • 平台:
  • 許可證: MIT License
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

Sammy

http://sammyjs.org

Description

Sammy is a tiny javascript framework built on top of jQuery inspired by Ruby's Sinatra.

Installation

Download Sammy.js and install it in your public javascripts directory.
Include it in your document AFTER jQuery.

Usage

Like Sinatra, a Sammy application revolves around 'routes'. Routes in Sammy are a little different, though. Not only can you define 'get' and 'post' routes, but you can also bind routes to custom events triggered by your application.

You set up a Sammy Application by passing a Function to the $.sammy (which is a shortcut for the Sammy.Application constructor).

$.sammy(function() {

  this.get('#/', function() {
    $('#main').text('Welcome!');
  });

});

Inside the 'app' function() this is the Application. This is where you can configure the application and add routes.

Above, we defined a get() route. When the browser is pointed to #/ the function passed to that route will be run. Inside the route function, this is a Sammy.EventContext. EventContext has a bunch of special methods and properties including a params hash, the ability to redirect, render partials, and more.

In its coolness, Sammy can handle multiple chained asynchronous callbacks on a route.

this.get('#/', function(context,next) {
  $('#main').text('Welcome!');
  $.get('/some/url',function(){
    // save the data somewhere
    next();
  });
}, function(context,next) {
  $.get('/some/other/url',function(){
    // save this data too
    next();
  });
});

Once you've defined an application the only thing left to do is run it. The best-practice behavior is to encapsulate run() in a document.ready block:

var app = $.sammy(...)

$(function() {
  app.run();
});

This will guarantee that the DOM is loaded before we try to apply functionality to it.

Dependencies

Sammy requires jQuery >= 1.4.1
Get it from: http://jquery.com

More!

Learn!

Keep informed!

Authors

Sammy.js was created and is maintained by Aaron Quint with additional features and fixes contributed by these talented individuals:

  • Frank Prößdorf / endor
  • Alexander Lang / langalex
  • Scott McMillin / scottymac
  • ZhangJinzhu / jinzhu
  • Jesse Hallett / hallettj
  • Jonathan Vaught / gravelpup
  • Jason Davies / jasondavies
  • Russell Jones / CodeOfficer
  • Geoff Longman
  • Jens Bissinger / dpree
  • Tim Caswell / creationix
  • Mark Needham
  • SamDeLaGarza
  • Mickael Bailly / dready92
  • Rich Manalang / manalang
  • Brian Mitchell / binary42
  • Assaf Arkin / assaf
  • James Rosen / jamesrosen
  • Chris Mytton
  • kbuckler
  • dvv
  • Ben Vinegar / benvinegar
  • Avi Deitcher / deitch

If you're using Sammy.js in production or just for fun, instead of gifting me a beer - please consider donating to the Code for Other People Fund. - you can probably spare a dollar or ten and it will be greatly appreciated.

License

Sammy is covered by the MIT License. See LICENSE for more information.

概覽

名稱與所有者quirkey/sammy
主編程語言JavaScript
編程語言Ruby (語言數: 3)
平台
許可證MIT License
發布數24
最新版本名稱v0.7.6 (發布於 )
第一版名稱v0.1.3 (發布於 )
創建於2009-03-20 03:30:06
推送於2020-09-10 13:46:25
最后一次提交2014-09-03 15:51:31
星數3k
關注者數97
派生數444
提交數784
已啟用問題?
問題數172
打開的問題數53
拉請求數47
打開的拉請求數17
關閉的拉請求數37
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?
去到頂部