This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Backbone Demo</title> | |
<script type="text/javascript" language="JavaScript" | |
src="http://cdnjs.cloudflare.com/ajax/libs/headjs/0.96/head.min.js"> | |
</script> | |
</head> | |
<body> | |
<div id="counter"> |
This file contains hidden or 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 window.MainController extends Backbone.Controller | |
class window.Counter extends Backbone.Model | |
defaults: | |
count: 00 | |
class window.CounterView extends Backbone.View |
This file contains hidden or 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
window.app = {} | |
app.controllers = {} | |
app.models = {} | |
app.views = {} | |
class window.MainController extends Backbone.Controller | |
routes : | |
"": "home" | |
"home": "home" |
This file contains hidden or 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
window.app = {} | |
app.controllers = {} | |
app.models = {} | |
app.views = {} |
This file contains hidden or 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 window.MainController extends Backbone.Controller | |
routes : | |
"": "home" | |
"home": "home" | |
home: -> | |
app.views.counter.render() |
This file contains hidden or 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 window.Counter extends Backbone.Model | |
defaults: | |
count: 0 |
This file contains hidden or 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 window.CounterView extends Backbone.View | |
initialize: -> | |
@counter = new Counter() | |
el: $('#counter') | |
events: | |
'click button#inc-count' : 'inc' | |
'click button#dec-count' : 'dec' |
This file contains hidden or 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
head.ready -> | |
app.controllers.main = new MainController() | |
app.views.counter = new CounterView() | |
app.models.counter = new Counter() | |
Backbone.history.start() |
This file contains hidden or 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 window.CounterView extends Backbone.View | |
initialize: -> | |
@counter = new Counter() | |
@counter.bind('change', @render) | |
el: $('#counter') | |
events: | |
'click button#inc-count' : 'inc' |
This file contains hidden or 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
from flask import Module, render_template, request, current_app, jsonify, session | |
mod = Module(__name__) | |
@mod.route('/') | |
def home(): | |
return render_template("base.html") | |
@mod.route('/api/counter', methods=['GET']) | |
def read(): |
OlderNewer