Skip to content

Instantly share code, notes, and snippets.

var AppRouter = Backbone.Router.extend({
routes:{
"":"index",
"test": function() {
console.log("Test method");
},
"foo": function() {
console.log("Foo method");
},
items.each do |category|
%li
%a{:href => " "}
= category.name
%script#container-fluid{ :type => 'text/template' }
.container-fluid{ :style => "border: solid 1px;" }
.sidebar
= render '/audio_player'
.content
%a{ :href => 'test'}
= "#{name}"
#footer
>>>
$(function() {
var app = new App.BeamRouter();
App.Models.mainPage = new App.Models.MainPage({ title: "Test title" });
App.Views.mainLayout = new App.Views.MainLayout({ model: App.Models.mainPage });
$("#main").empty().append(App.Views.mainLayout.el);
App.Views.mainLayout.render();
Backbone.history.start({pushState: true});
});
%script#album-row{ :type => 'text/template' }
.album-row
<a href = "<%= id %>"><%= updated_at %></a>
.song-row
%p Something
@psykidellic
psykidellic / gist:3397903
Created August 19, 2012 21:42
Text with error
- if resource.errors.any?
.alert.alert-block.alert-error
%h4.alert-heading
= pluralize(@session.errors.count, "error")
with form:
%ul
- @session.error.full_messages.each do |msg|
%li= msg
%span.control-group.error
App.Views.AlbumView = Backbone.Layout.extend({
manage: true,
template: "#album-row",
className: "album-row",
events: {
"click i.icon-play": "playAlbum"
},
@psykidellic
psykidellic / gist:3419918
Created August 21, 2012 22:17
CoffeeScript examples
foo ->
console.log( 'foo' )
boo($) ->
console.log($)
(baz( ) ->
console.log(arguments)
)("foo")
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Test Thing</title>
<script src="underscore.js" type="text/javascript" charset="utf-8"></script>
<script src="backbone.js" type="text/javascript" charset="utf-8"></script>
<script src="santoor.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
class @Santoor extends Backbone.View
constructor: (@templateId) ->
render: ->
console.log @templateId
template = _.template($(@templateId).html())
// if I remove the constructor part and use
// template = _.template($("#santoor-player").html())
// it works