def load_more_laws(obj_response, group_name, status_name, order, last):
laws = Law.get_more(group_name=group_name, status_name=status_name, order=order, last=last)
render_law = get_template_attribute('macros.html', 'render_law')
more_laws_panel = get_template_attribute('macros.html', 'more_laws_panel')
if laws:
for law in laws:
obj_response.html_append('#laws-container', render_law(law, current_user, actions_footer=True).unescape())
if order == 'id':
panel = more_laws_panel(group_name, status_name, order, laws[-1].id).unescape()
elif order == 'date':
panel = more_laws_panel(group_name, status_name, order, laws[-1].date).unescape()
else:
return
obj_response.html('#load_more_container', panel)
# refresh masonry to load the new laws correctly
obj_response.script('$(".masonry-grid").masonry( "reloadItems" )')
obj_response.script('$(".masonry-grid").masonry()')
# refresh and re-enable waypoint to achieve continuous loading
obj_response.script('Waypoint.refreshAll()')
obj_response.script('Waypoint.enableAll()')
else:
obj_response.html('#load_more_container', more_laws_panel().unescape())
评论列表
文章目录