I'm trying to understand and implement Ajax in Web2py with the reddit_clone 
tutorial

Is there a prerequisite or something else I am missing?

The following should be quite verbatim

{{for data in rows:}}
<div class="well">
    <table>
        <tr data-id="{{data.id}}"><td><button 
data-direction="down">-</button></td><td><span 
class="votes">{{=data.votes}} </span></td><button 
data-direction="up">+</button>
            <td><strong>{{=A(data.name + ' - ' + 
data.info,_href=URL('view_data',args=data.id))}}</strong></td></tr>
    </table>

</div>
{{pass}}



<script>
function do_ajax_vote(t.direction) {
    var id = jQuery(t).closest('div').attr('data-id');
    alert('clicked');
}

jQuery(function() { // registers the callback
    
jQuery('[data-direction=up').click(function(){do_ajax_vote(this,'up');});
    
jQuery('[data-direction=down').click(function(){do_ajax_vote(this,'down');});
});
</script>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.

Reply via email to