Is the below your exact code? I ask because in stats_del, you refer to a 
variable a0 that has not been defined (presumably it is request.args(0)). 
Also, your click handler refers to a ".del-div" class, but I don't see any 
elements with that class.

Anyway, by default, if an incoming URL has no extension, .html is assumed, 
so:

{{=LOAD('user','stats', args=[user.id], target='stats-ajax', ajax=True,content
='')}}

will look for a /views/user/stats.html view. If you instead want to use a 
stats.load view, you have to explicitly specify the .load extension:

{{=LOAD('user','stats.load', args=[user.id], target='stats-ajax', 
ajax=True,content
='')}}

Finally, this:

URL(TIP_APP+'/user', 'stat_del', str(row.id))

is the wrong way to call the URL function. It happens to work in your case 
by accident (the first argument is interpreted as the app, the second as 
the controller, and the third as the function, when in fact the first is 
really the app+controller, the second the function, and the third is an 
arg). Instead, it should be:

URL(TIP_APP, 'user', 'stat_del', args=str(row.id))

or more simply:

URL('user', 'stat_del', args=str(row.id))

Note, you can leave out the app name, as it will get included automatically.

Anthony

On Sunday, February 23, 2014 11:15:32 PM UTC-5, Dan M wrote:
>
> 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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to