This file contains 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
This Gist is for the case where your html is generated on the server side, but you still want to use Backbone to manage | |
the incremental user actions. The idea is to parse the already rendered DOM and create the model / collection on the | |
first time, hence we can still follow the Backbone pattern to update models and the bindings reflect view and update server etc. | |
Lets do step by step for the infamous TODO application: | |
Step 1) Add a function dom2coll() to the AppView that will parse the rendered DOM and convert to data. | |
dom2coll: function() { | |
// To update model/view from already rendered DOM from backend. |
This file contains 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
MongoDB provides a Javascript shell. But Javascript is no fun without underscore.js | |
Turned out its straight forward to use underscore.js while scripting mongodb. | |
Here are the steps. | |
1) Use underscore to write your db script file (say my_commands.js) | |
E.g: _.each(db.dbname.find().toArray(), function(itm) { ... }) |