edit buttons within FOR loop

32 views
Skip to first unread message

Alex Glaros

unread,
Nov 6, 2014, 8:09:14 PM11/6/14
to web...@googlegroups.com
are there examples of edit buttons within FOR loop as I inserted in the Reddit-Clone example below?

{{extend 'layout.html'}}
<h2>Comments for {{=A(news.title,_href=news.link)}}</h2>

{{if auth.user:}}
  <span id="votes">{{=news.votes}}</span>
  <button id="plus" onclick="ajax('{{=URL('vote',args=(news.id,'plus'))}}',[],':eval')">plus</button>
  <button id="minus" onclick="ajax('{{=URL('vote',args=(news.id,'minus'))}}',[],':eval')">minus</button>
  {{=form}}
{{pass}}
<table>
  {{for comment in comments:}}
  <tr>
    <td>{{=comment.posted_on}}</td>
    <td>{{=comment.posted_by.first_name}} says </td>
    <td>{{=MARKMIN(comment.body)}}</td>
    <td>IF is_owner, display EDIT, and DELETE buttons.</td>  <!-- these are automatically created in SQLFORM.grid, but how to insert them here? -->
  </tr>
  {{pass}}

thanks,

Alex Glaros

Leonel Câmara

unread,
Nov 7, 2014, 5:24:42 AM11/7/14
to web...@googlegroups.com
Is something like this what you want?

  {{for comment in comments:}}
  <tr>
    <td>{{=comment.posted_on}}</td>
    <td>{{=comment.posted_by.first_name}} says </td>
    <td>{{=MARKMIN(comment.body)}}</td>
    <td>
    {{if auth.user_id == comment.posted_by:}}
        <button>Edit</button>
    {{pass}}
    </td>
  </tr>
  {{pass}}

Alex Glaros

unread,
Nov 7, 2014, 12:12:29 PM11/7/14
to
Thanks Leonel, sorry I wasn't clear, am interested in working example where vars are passed so I can see how they and edit functions work.  If you know of any example, please let me know.

Alex Glaros

Reply all
Reply to author
Forward
0 new messages