What is exactly happening?

The votesup field is not being added or the updated result is not being showed?
Using some inspection tool, is your default/voteup() function being invoked?
What did you already tried?

Help us help you.



On Fri, May 10, 2013 at 3:46 PM, sasogeek <sasog...@yahoo.com> wrote:
> I need help.....
>
> On Friday, 10 May 2013 16:53:23 UTC+1, sasogeek wrote:
>>
>> Model
>> db.define_table('content',
>>     Field('username'),
>>     Field('text', 'text'),
>>     Field('file', 'upload'),
>>     Field('userpicture'),
>>     Field('time', 'datetime', update=request.now),
>>     Field('userid', readable=False),
>>     Field('votesup', 'integer', default=0),
>>     Field('votesdown', 'integer', default=0)
>> )
>>
>>
>> Controller (default.py)
>> def feed():
>>     #postform
>>     postform = crud.create(db.content, next='feed')
>>     postform['_id']='postform'
>>     ...
>>     votesup = postform.element('input', _name='votesup')
>>     votesup['_type']='hidden'
>>     votesdown = postform.element('input', _name='votesdown')
>>     votesdown['_type']='hidden'
>>     contents = db().select(db.content.ALL, orderby=~db.content.id)
>>     return dict(postform=postform, contents=contents)
>>
>> def voteup():
>>     item = db.content[request.vars.id]
>>     new_votes = item.votesup + 1
>>     item.update_record(votesup=new_votes)
>>     return str(new_votes)
>>
>>
>> View (default/feed.html)
>> {{for content in contents:}}
>> ...
>> <span onclick="jQuery('#postform').val('{{=content.id}}'); ajax('voteup',
>> ['votesup'], 'content{{=content.id}}');" style='padding:10px;'>
>>     <img src='../static/images/thumbsup.png' style='height:20px;
>> width:20px;'/></span>
>> <span id='content{{=content.id}}' >{{=content.votesup}}</span>
>>
>> {{pass}}
>>
>> When I click the image in the view "thumbsup.png", the votesup count
>> doesn't increase... what am i doing wrong?
>>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to