Skip to content

Instantly share code, notes, and snippets.

We couldn’t find that file to show.
We couldn’t find that file to show.
//
// goal: load in data, then template
//
var nav = $.sammy('#mainNav',function(){
this.use(Sammy.Mustache,'ms');
this.get('#/', function() {
this.load('data/nav.json')
.render('templates/nav.ms') // render will take the previous data as the `data` arg for rendering
.swap();
var myApp = $.sammy(function() {
this.helpers({
loadIndex: function() {
// you can do everything you would do in a route here.
}
});
this.get('#/index', function() {
this.loadIndex();
@quirkey
quirkey / nicer.rb
Created November 1, 2010 00:12 — forked from mrb/nicer.rb
class Engine
include Achievements::AchievementsEngine
achievements do
:context1 do
achieve {:name => :one_time, :threshold => 1}
end
:context2 do
achieve {:name => :one_time, :threshold => 1}
$.sammy(function() {
var h = "";
this.bind('run', function() {
$(window).bind('scroll', function() {
// find nearest `h` and set it to $h
h = $h.attr('id');
// redirect to the new location
this.redirect('#', 'area', h);
});
We couldn’t find that file to show.
$.sammy(function() {
this.helpers({
clear: function() {
$('#main').html('');
}
});
this.before(function() {
this.clear();
parseResponse: function(response) {
try {
if (typeof response == "string") {
return JSON.parse($(response).text());
} else {
return response;
}
} catch(e) {
Sammy.log("parseResponse Error:", response, e);
return {};
this.get('#/', function(ctx) {
this.load($('#action-index'))
.replace('#main')
.async(Action.all)
.then(function(content) {
ctx.log('should wait', content);
})
.then(hideLoading);
});