Reputation: 365
When a user visits a magazine page, a button should appear that will allow the currently logged in user to subscribe to a particular magazine if that user is already logged in. The button should not be visible to an anonymous user.
I have gotten the button to show up when the user has logged in, but clicking on the button doesn't call my controller function.
If this is the controller function:
@auth.requires_login()
def subscribe():
mag_id = request.args(0, cast=int)
db.subscribe.insert(magazine=mag_id, subscriber=auth.user.id)
And this is the part of the views:
<div>
{{=magazine.title}}
{{=magazine.description}}
</div>
<div>
{{ if auth.is_logged_in():}}
{{=A('subscribe', _class="btn_subscribe", callback=URL("subscribe", args=magazine.id))}}
{{pass}}
</div>
The <a>
button shows up as this:
<a href="#null" onclick="ajax('/myapp/default/subscribe/3',[],'me');return false">subscribe</a>
And the controller function is never called, and the user is never subscribed.
Upvotes: 1
Views: 993