In the following code, when pressing the "X" link, the row and DIV are
deleted and the component is refreshed in the controller function
stat_del(). This only works when the loaded component is named ".html"
rather than ".load" So this code works but the ".load" naming does not
work.
***********************************
*** CONTROLLER: user.py ***
***********************************
def stats():
user = session.r_cur_user
tipuser = session.r_tip_user
query = (Stat.crea_id==user.id)
rows = db(query).select(orderby=~Stat.time_stamp)
return locals()
def stat_del():
db(Stat.id==a0).delete()
response.js = "jQuery('#stats-ajax').get(0).reload();"
return locals()
*********************************
*** LOADED: stats.html ***
*********************************
{{for row in rows:}}
<div class='tip-del-div-wrapper'>
<div class='tip-del-div'>{{=A('X', _class="tip-del",
_style="margin-top: 2px;", callback=URL(TIP_APP+'/user', 'stat_del',
str(row.id)))}}</div>
</div>
<div class='tip-body tpf-body'>
<p class="expand-desc tpf-body" style='margin-left: 6px; margin-right:
18px;'>{{="Status goes here"}}</p>
<p class="expand-desc tpf-body" style='margin-left: 6px;'>{{="Time
stamp goes here"}}</p>
</div>
{{pass}}
<script>
$('.del-div').on('click', function(){
$(this).parent().parent().remove();
});
</script>
************************************
*** MAIN VIEW: home.html ***
************************************
{{left_sidebar_enabled,right_sidebar_enabled=True,True}}
{{extend 'layout.html'}}
{{block profile}}
{{=LOAD('user','profile',user.id,ajax=True, content='')}}
{{end}}
{{block follows}}
{{=LOAD('user','friends',user.id,ajax=True, content='')}}
{{end}}
{{block center}}
<div class="tabbable">
<ul class="nav nav-tabs">
<li class="active"><a href="#tab3" data-toggle="tab">Status</a></li>
<li><a href="#tab2" data-toggle="tab">Received</a></li>
<li><a href="#tab1" data-toggle="tab">Given</a></li>
</ul>
<div class="tab-content" style="overflow-x:hidden;">
{{if user.creator:}}
{{block stats}}
<div class="tab-pane active" id="tab3"
style="width:100%;height:70%;overflow-y:auto; overflow-x:hidden;">
{{if mypage:}}
{{=LOAD('user','stat', args=[user.id], target='stat-ajax',
ajax=True, content='')}}
{{pass}}
{{=LOAD('user','stats', args=[user.id], target='stats-ajax',
ajax=True, content='')}}
</div>
{{end}}
{{pass}}
</div>
</div>
{{end}}
--
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.