Permalink
Browse files

trying to get a resource object working.

  • Loading branch information...
1 parent f0271ca commit fe91fb438dc641556c4a76e4d726d9b468c94c10 @ernstnaezer ernstnaezer committed Aug 31, 2011
Showing with 9 additions and 4 deletions.
  1. +9 −4 js/lib/SS.js
View
@@ -3,7 +3,10 @@
var dloc = document.location;
function regify(routes) { // convert all simple param routes to regex
- for (var key in routes) {
+
+ if (typeof routes === 'string') return;
+
+ for (var key in routes) {
regify(routes[key]);
if (key.indexOf(':') !== -1) {
var newKey = key.replace(/:.*?\/|:.*?$/g, '([a-z0-9-]+)/').slice(0, -1);
@@ -47,13 +50,14 @@
regify(this.routes);
function dispatch(src) {
+
for (var i=0, l = self[src].length; i < l; i++) {
var listener = self[src][i];
var val = listener.val === null ? self.lastroutevalue : listener.val;
-
+
if (typeof listener.fn === 'string') {
- listener.fn = self.resource[listener.fn];
+ listener.fn = self.resource[listener.fn];
}
if (typeof val === 'string') {
@@ -129,7 +133,8 @@
if (len === 0 || self._recurse) {
function queue(fn, type) {
- if(fn && fn[0]) {
+
+ if(fn && fn.constructor == Array) {
for (var j = 0, m = fn.length; j < m; j++) {
self[type][add]({ fn: fn[j], val: matched || path });
}

0 comments on commit fe91fb4

Please sign in to comment.