It looks like you're starting at the beginning and using modals can be a 
headache.  
On a general note,  I believe we can best make progress using small steps,  
so I recommend...

   - Start by creating a form in your controller.
   - Display the form in your view inside a hidden div.  
   - Then when you click the Add button, simply show the form with 
   Javascript.
   - Once you've got that working.  Re-work the view to do the same thing 
   using a modal.

This will be a good way to get where you want to go!

Best wishes,  D


On Tuesday, 30 April 2019 05:54:03 UTC+1, Cristina Sig wrote:
>
> Hello everyone,
>
>
> I have a button to add records. What I am trying to do is when I click on 
> it I want to display a modal that contains a Crud form to create/add a new 
> record. 
>
> Something like this Example 
> <https://editor.datatables.net/examples/simple/simple.html>
>
> Any suggestions to do that?
> This is my try
>
>
> Controller
>
> def Person():
>     person= db(db.Person.id>0).select()
>     return dict(formListar=person)
>
>
> View
>
> <script>
>  $('#add').click(function(e) {
>  e.preventDefault();
>  btn = $(this);
>  thisHref = btn.attr('href');
>  $('#myModalAdd').modal('show')
>  .one('click', '#warning', function(e) {
>     window.location = thisHref;});
>  });
> </script>
>
>
> <a class="btn btn-default" id="add" 
> href="/{{=request.application}}/Tools/AddPerson"><span 
> class="glyphicon glyphicon-plus"></span> Add Person</a>
>
>
> <div id="myModalEdit" class="modal fade">
>   <div class="modal-dialog" role="document">
>     <div class="modal-content">
>       <div class="modal-header">
>        <h4 class="modal-title">Add Person</h4>
>       </div>
>       <div class="modal-body">
>        <p>
>            {{=formListar}}
>        </p>
>       </div>
>       <div class="modal-footer">
>       </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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to