Creating new records and updating the component to show the newly created
record works.
What does not work is to load a new record into the bootstrap modal form.
What am I doing wrong in the post.load views and then in the
comments.py.get_comment code?
*models/tables.py*
db.define_table('comment_post',
Field('title','string',label='Comment title', requires=IS_NOT_EMPTY()),
Field('body','text',label='Your comment', requires=IS_NOT_EMPTY()),
auth.signature)
*controllers/default.py*
def index():
return dict()
*views/default/index.html*
{{extend 'layout.html'}}
<h3>Comments</h3>
{{=LOAD('comments','post.load',ajax=True)}}
*controllers/comments.py*
@auth.requires_login()def post():
return dict(form=SQLFORM(db.comment_post,
formstyle='bootstrap3_stacked').process(),
comments=db(db.comment_post).select(orderby=~db.comment_post.id, limitby=(0,
3)))
@auth.requires_login()def get_comment():
r = db.auth_user(request.vars.id) or redirect(URL('index'))
form = SQLFORM(db.comment_post, r)
return form
*views/comments/post.load*
{{for post in comments:}}
<div class="post">{{=post.title}}: on <small>{{=post.created_on}}</small>
{{=post.created_by.first_name}}
<small>said:</small> "<span class="post_body">{{=post.body}}</span>"
{{=A('Edit', callback=URL('welcome', 'comments', 'get_comment',
vars={'id': post.id}), target="form_load")}}
</div>
{{pass}}
<hr>
<button type="button" class="btn btn-primary btn-lg" data-toggle="modal"
data-target="#myModal">
Launch demo modal</button>
<!-- Modal --><div class="modal fade" id="myModal" tabindex="-1" role="dialog"
aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Modal title</h4>
</div>
<div id="form_load" class="modal-body">
{{=form}}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default"
data-dismiss="modal">Close</button>
</div>
</div>
</div></div>
--
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/d/optout.