Oke gr8!!! will give it a shot!!! thanx you guys, so much to learn!! wb2py rocks!!
On 11/8/12, Paolo Caruccio <[email protected]> wrote: > a possible solution (skeleton code so please check for errors and > omissions): > > # controllers > def companies(): > return dict() > > def add_company(): > form = SQLFORM(db.company, formstyle='bootstrap') > if form.process().accepted: > session.flash = 'form accepted' > redirect(URL('add_company', vars={'success':'ok'})) > elif form.errors: > response.flash = 'form has errors' > else: > pass > return dict(form=form) > > > # view = companies.html > {{extend 'layout.html'} > > <!-- Button to trigger modal --> > <a href="#myModal" class="btn" data-toggle="modal">Launch modal</a> > > <!-- Modal --> > <div id="myModal" class="modal hide fade"> > <div class="modal-header"> > <button type="button" class="close" data-dismiss="modal">×</button> > > </div> > <div class="modal-body"> > {{=LOAD('default', add_company.load', ajax=True, ajax_trap=True)}} > </div> > <div class="modal-footer"> </div> > </div> > > <script type="text/javascript"> > jQuery('#myModal').on('hidden', function () { > // ajax call to refresh data grid > }) > </script> > > > # view = add_company.load > {{=form}} > > <script type="text/javascript"> > jQuery(document).ready(function(){ > var res = '{{=request.vars.success}}' > if (res != 'None') { > jQuery('#myModal').modal('hide'); > }; > }); > </script> > > > > Il giorno giovedì 8 novembre 2012 16:52:46 UTC+1, software.ted ha scritto: >> >> Hi, >> >> How do I auto close a JS Bootstrap modal window that has simple form >> and then update a grid on the calling main page??? I am using >> Bootstrap modal window. >> >> Model: >> db.define_table('department', Field('name')) >> db.define_table('office', Field('name'), Field('department', >> db.department)) >> >> Controller: >> def add_department(): >> form=SQLFORM(db.department) >> if ..: >> ... >> else: >> ... >> return dict(form=form) >> >> def add_office(): >> form = SQLFORM(db.office) >> if ...: >> ... >> else: >> .... >> add_department.load: >> {{=form}} >> add_office.load: >> {{=form}} >> >> What I want in the view is to be able to add a company using a >> bootstrap modal window after clicking on save close the modal window >> and update a grid with a new company added in the same window. Also I >> when i add office modal window, in the dropbox i want to see the just >> added company without refreshing the main winnow but using ajax. >> >> Any ideas pointer...thanx in advance... >> enalapril + nifedipin + pediatric benlin >> >> Teddy L. >> >> /~ >> > > -- > > > > -- ....................................................................................... Teddy Lubasi Nyambe Opensource Zambia Lusaka, ZAMBIA Cell: +260 97 7760473 website: http://www.opensource.org.zm ~/ Human Knowledge belongs to the world! - AntiTrust Man is a tool-using animal. Without tools he is nothing, with tools he is all - Thomas Carlyle 1795-1881 /~ --

