before filter with async call

15 views
Skip to first unread message

Michael Bykov

unread,
May 15, 2013, 5:33:41 AM5/15/13
to sam...@googlegroups.com
Hi,

I have before filter which save 2 variables in local store

app = $.sammy '#container', () ->
    store = new Sammy.Store {name: 'name', type: 'local'}
    this.use(Sammy.Template, 'tpl');
...
    this.before () ->
       if not store.exists("site")
           store.load "site", "/templates/contents.tpl"
           console.log "site"
       if not store.exists("lib")
           store.load "lib", "/mycouch/some_id"
           console.log "lib"

    this.get '^\/$', (ctx) ->
        console.log "home"


both are remote async call to couchdb. First - usual sammy.js plugin method. The second - simple GET request to couchdb's database "mycouch"

first works as expected before a main route, but second not. So I've got in firebug:

> site
> home
> lib

I have got correct values for both site and lib, but lib not works as before filter, alas.

Where is my mistake?
Reply all
Reply to author
Forward
0 new messages