Using client-side routes with zappa/sammy #107

hudon opened this Issue Nov 5, 2011 · 2 comments


None yet
2 participants

hudon commented Nov 5, 2011

Zappa Docs say that you can do @ get, post, put, del in browser-side code (section "CLIENT-SIDE ROOT SCOPE"). Looking around the docs, and then at the source (0.3.1), I see zappa is exposing Sammy's routing functionality to do so.
Only @ get is being exposed though, so:

@client '/foo.js': ->
  @get '#/': ->
    alert 'bar'
  @post '#/banana': ->
    alert 'ban'

@ post will throw an error as soon as it is read: "Uncaught TypeError: Object # has no method 'post'"

I tried doing: '#/banana': ->

but that ends up causing 'has no method 'exec'' in the sammy.js code.

hudon commented Nov 5, 2011

in the meantime I can just use @ get for all client side routing without a problem

I met same problem, but after reading the code, I understand the direct reason.

For the '@post' error, it is not supported by zappa's client context, please refer:

For the "has no method 'exec" error, it is because of the non-adaptive api interface between zappa and sammy.
zappa use object literals to passing params, while sammy use normal function param-passing.
Carefully read the code below and compare with sammy api

But I do not understand the rationale why zappa keep a limited use of sammy apis.

Hope anybody could give an explanation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment