Skip to content

Commit

Permalink
update couchapp vendor
Browse files Browse the repository at this point in the history
  • Loading branch information
jchris committed Mar 27, 2010
1 parent 436ea05 commit 4cab5ba
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 6 deletions.
12 changes: 12 additions & 0 deletions vendor/couchapp/_attachments/jquery.evently.js
Expand Up @@ -145,6 +145,9 @@ function $$(node) {
if (h.query && !qrun) {
// $.log("query before renderElement", arguments)
runQuery(me, h, args)
} else if (h.async && !qrun) {
$.log("runAsync")
runAsync(me, h, args)
} else {
// $.log("renderElement")
// $.log(me, h, args, qrun)
Expand Down Expand Up @@ -183,6 +186,15 @@ function $$(node) {
runIfFun(me, h.partials, args)));
};

function runAsync(me, h, args) {
var app = $$(me).app;
// the callback is the first argument
funViaString(h.async).apply(me, [function() {
renderElement(me, h, arguments, true);
}].concat(args));
};


function runQuery(me, h, args) {
// $.log("runQuery: args", args)
var app = $$(me).app;
Expand Down
7 changes: 2 additions & 5 deletions vendor/couchapp/_attachments/jquery.pathbinder.js
Expand Up @@ -32,15 +32,12 @@
}
})
},
go : function (path) {
go : function(path) {
goPath(path);
triggerOnPath(path);
},
onChange : function (fun) {
$.pathbinder.changeFuns.push(fun);
},
changed : function(path) {
$.pathbinder.changeFuns.forEach(function(fun) {fun(path)});
}
};

Expand All @@ -62,7 +59,7 @@
}

function triggerOnPath(path) {
$.pathbinder.changed(path);
$.pathbinder.changeFuns.forEach(function(fun) {fun(path)});
var pathSpec, path_params, params = {};
for (var i=0; i < $.pathbinder.paths.length; i++) {
pathSpec = $.pathbinder.paths[i];
Expand Down
28 changes: 27 additions & 1 deletion vendor/couchapp/docs/evently.md
Expand Up @@ -156,4 +156,30 @@ Evently understands CouchDB in a couple of very simple ways. If you know CouchDB

-- links to example apps

A tour of Taskr
## Freeform Asynchronous Actions

Watch out, you're dangerous! Evently allows you to make any old asyncronous action you want, with the `widget.async` member. The callback is the first argument to the `async` function. Check it out:

$("#async").evently({
_init : {
mustache : "<p>How many databases on the local host?</p><p>Answer: {{number_of_dbs}}</p><p>Other stuff: {{args}}</p><p>More: {{allArgs}}</p>",
async : function(cb) {
var ag = Array.prototype.slice.call(arguments).map(function(a){return a.toSource ? a.toSource() : a});
$.couch.allDbs({
success : function(resp) {
cb(resp.length, ag);
}
})
},
data : function(count, args) {
return {
number_of_dbs : count,
args : JSON.stringify(args),
allArgs : JSON.stringify(Array.prototype.slice.call(arguments))
};
}
},
click : {
mustache : "<p>What a crazy world!</p>",
}
});

0 comments on commit 4cab5ba

Please sign in to comment.