This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Engine | |
include Achievements::AchievementsEngine | |
achievements do | |
:context1 do | |
achieve {:name => :one_time, :threshold => 1} | |
end | |
:context2 do | |
achieve {:name => :one_time, :threshold => 1} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.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); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.sammy(function() { | |
this.helpers({ | |
clear: function() { | |
$('#main').html(''); | |
} | |
}); | |
this.before(function() { | |
this.clear(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this.get('#/', function(ctx) { | |
this.load($('#action-index')) | |
.replace('#main') | |
.async(Action.all) | |
.then(function(content) { | |
ctx.log('should wait', content); | |
}) | |
.then(hideLoading); | |
}); |