Skip to content

Instantly share code, notes, and snippets.

@cjblomqvist
Created July 2, 2013 20:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cjblomqvist/5913048 to your computer and use it in GitHub Desktop.
Save cjblomqvist/5913048 to your computer and use it in GitHub Desktop.
var app = require('derby').createApp(module)
;
app.get('/*', function(page, model, params) {
model.set('_page.unplannedOrder', [{"id":"1"}, {"id":"2"}, {"id":"3"}]);
page.render('');
});
app.enter('/*', function (model) {
model.remove('_page.unplannedOrder', 0);
model.set('_page.selected.3', true); // Triggers red backround on wrong li on the top ul (li above - aka #2)
});
app.view.fn({
/**
* Alternative to the buggy binding-implementation of myPath[myKey]
* E.g. where:
* myKey = 1
* myKey2 = 0
* {multiplePartPath(myPath, myKey, "property", mySecondKey)}
* will result in a dynamic version of:
* {myPath.1.property.1}
* @param {Object} basePath The base path already converted to an object (e.g. the path without quotes)
* @param {String/Key} leaf A leaf as a string, either directly or indirectly through a variable (which thus will be converted to a string through Derby)
* @return {Value} The returning value
*/
multiplePartPath: function (basePath) {
var argumentsLength = arguments.length
;
for(var i = 1; i < argumentsLength && typeof basePath !== 'undefined'; i++) {
basePath = basePath[arguments[i]]
}
return basePath;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment