Skip to content

Instantly share code, notes, and snippets.

View alexandernst's full-sized avatar

Alexander Nestorov alexandernst

View GitHub Profile
@alexandernst
alexandernst / eventbuscall.js
Created July 18, 2012 08:10
EventBus call from server side
<?php
// handle file ...
// more stuff ...
?>
<script language='javascript' type='text/javascript'>
window.top.window.EventBus.dispatch("upload_done", this, 42);
</script>
@alexandernst
alexandernst / myview.js
Created July 18, 2012 08:07
Backbone View listening for finished uploads
var myView = Backbone.View.extend({
events: {
'click .start_upload': 'start_upload'
}
initialize: function(){
EventBus.addEventListener("upload_done", this.upload_callback);
}
@alexandernst
alexandernst / e404.js
Created June 24, 2012 14:36
Backbone Error 404
window.APP = Backbone.Router.extend({
initialize: function(){
this.route(/.*?/, "e404");
this.route(/^$/, 'mainPage');
//Some other routes
},
e404: function(){
console.log("Error 404!");
@alexandernst
alexandernst / views.js
Created June 24, 2012 13:30
Backbone Views creation
window.App = Backbone.Router.extend({
initialize: function(){
this.route(/^$/, 'mainPage');
}
mainPage: function(){
console.log("Showing main page...");
var content = $('#content');