I want a solution to keep view and post actions on the same function, by verifying if the user submited some data.
My total.js controller is like this
# framework
exports.install = (framework) ->
framework.route "/subscribe", subscribe
framework.route "/subscribe", subscribe, ['post']
# subscribe form and action
subscribe = ->
self = this
post = self.post
if post
Subscriber = self.model('subscriber')
Subscriber.save post
self.view "form"
The problem is that post is {} when I'm just viewing the page (not submiting data), so it always enter on if.
If I compare to {} (if post isnt {}) the condition is always false, probably because self.post is not an empty object.
[update]
When viewing the page:
console.log post #logs {}When submiting the form:
console.log post #logs { type: 1, email: "email@example.com" }