Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using client-side routes with zappa/sammy #107

Open
hudon opened this issue Nov 5, 2011 · 2 comments
Open

Using client-side routes with zappa/sammy #107

hudon opened this issue Nov 5, 2011 · 2 comments

Comments

@hudon
Copy link

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:

@app.post '#/banana': ->

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

@hudon
Copy link
Author

hudon commented Nov 5, 2011

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

@mountain
Copy link

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:
https://github.com/mauricemach/zappa/blob/master/src/client.coffee

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
https://github.com/mauricemach/zappa/blob/master/src/client.coffee#L17

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants