![]() ![]() This is less complex than the Todos example but more or less does the same thing in terms of allowing the user to input basic data (in this case a link and a description), delete it, and have it be restored from local storage upon reloading the app in the same browser later on. ![]() I wanted to try and implement something similar to the Todos example myself, sort of from scratch, and without using a server-side data storage (at first). By the way, having the console open with this one is useful, it will show you more about what is going on, in terms of the Routing.īackbone.sync using local storage: this example uses the backbone-localstorage.js module provided along with the Todos example in the default distribution. ![]() It's not immediately apparent what the function of routing in Backbone.js is, so I applied my own opinionated (but not original) interpretation here: it should be a way to respond in an event-driven fashion to RESTful urls. I'll try to track them down and put in appropriate attribution, but if they are yours and you want me to take them down or give you credit just drop me a line (see my email below, or contact me via github). I may re-factor this in the future to provide some more simplicity. The collection example ended up being a bit more complex than I had intended, and kind of "smells," but I probably learned the most on this one. Much of this class's utility comes from the great Underscore.js library, which, being a Ruby coder, made me feel right at home. It implements a simple up/down counter.Ĭollections give one the ability to manipulate Models as.collections of objects. This example simply shows how a click event can be caught in a hopefully "idiomatically" fashion. Backbone.js doesn't provide much guidance on how to use its View's render() method (by design), and the example given in the docs is a rather confusing mishmash of Backbone.js, underscore.js functionality and jQuery, so it took me a bit to sort through it all.Įvents are a core aspect of Backbone.js, and provide the support for its smooth implementation of automatic updating of various DOM elements, one of Backbone.js's true strengths I believe. First I wanted to understand how to dump out Model data to Templates. Super Basic 1 - This is basically "hello world" in Backbone.js. The code examples represent self-tutorials (or "explorations" or what-have-you) which progress roughly in terms of complexity, and in terms of what I thought were the basic concepts which I wanted to grasp, in the order I wanted to grasp them. However, there are definitely some ways that Backbone.js "suggests" you should structure your code, and it is hard to figure these out with what the official docs provide, outside of trial-and-error messing around and navigating the collection of sometimes out-of-date/badly/awkwardly/unconvincingly written tutorials and documentation resources online (although for the record there's a tremendous amount of great stuff online as well). The motivation behind this was that the official Backbone.js reference, while filled with useful information, suffers a bit from being "too close too the code." Many things are glossed over with the reasoning that Backbone.js is open-ended and doesn't restrict you (which is true). This is a collection of simple apps meant to illustrate and explore various techniques used in building Backbone.js apps. NOTE: web development moves fast, and these may be out of date. ![]() ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |