background preloader


Facebook Twitter

ClearTimeout on dynamically updating timer. I've got a timer that I'm updating dynamically.

clearTimeout on dynamically updating timer

------------------update -------------------------- when I first posted the question, I didn't think it mattered that the timer was being called from within a backbone view, but I believe as a result of that, I can't use a global variable (or at least a global variable isn't working). I'll be calling multiple timers, so setting only one global variable and deleting it won't work. I need to be able to clear a single timer without clearing the others. What I start the timer, function countDown(end_time, divid){ var tdiv = document.getElementById(divid), to; this.rewriteCounter = function(){ if (end_time >= MyApp.start_time) { tdiv.innerHTML = Math.round(end_time - MyApp.start_time); } else { alert('times up'); } }; this.rewriteCounter(); to = setInterval(this.rewriteCounter,1000); } in my app, I initiate the timer in a backbone view with.

Building a single page app with Backbone.js, underscore.js and jQuery. Overview We've been finding ourselves building more and more JS heavy apps here at &yet.

Building a single page app with Backbone.js, underscore.js and jQuery

Until recently, we've pretty much invented a custom app architecture for each one. Not surprisingly, we're finding ourselves solving similar problems repeatedly. On the server side, we use django to give us an MVC structure to follow. But there's no obvious structure to your client-side code. But for those of us who want to lovingly craft the UI exactly how we want them in the JavaScript we know and love, and yet crave quick lightweight solutions, those toolkits feel like overkill.

Recently something called Backbone.js hit my "three tweet threshold" I decided to take a look. The Problem There are definitely some challenges that come with building complex, single-page apps, not the least of which is managing an ever increasing amount of code running in the same page. The Goals So, how do we want our app to behave? Enter Backbone.js The Model object.

(37) What are some good resources for Backbone.js. Getting Started with Backbone.js. Unlike its web development peers, JavaScript has never really had much in the way of frameworks to provide structure.

Getting Started with Backbone.js

Thankfully, in recent years, that's beginning to change. Today, I'd like to introduce you to Backbone.JS, a sweet little library that makes the process of creating complex, interactive and data driven apps so much easier. It provides a clean way to surgically separate your data from your presentation. Overview of Backbone.JS Created by Jeremy Ashkenas, the JS ninja who built CoffeeScript, Backbone is a super light-weight library that lets you create easy to maintain front ends. Backbone is a collection of cohesive objects, weighing in at a shade under 4kb, that lend structure to your code and basically helps you build a proper MVC app in the browser. Let's face it: the above is a little hard to parse and make sense of. Key-value binding and custom events Rich API of enumerable functions Views with declarative event handling Your days of writing spaghetti bind calls are over. Backbone.js Tutorials.