[web2py] Re: Modal form window
I am building my code on this idea. Here, it is not accepting web2py_component in javascript. [CODE] function editURL( depId, depNm){ var urlTarget = {{=URL('frmDeptEdt')}}; {{web2py_component(urlTarget+/+depId+/+depNum, 'deptEdt')}}; jQuery( #deptEdt ).dialog('open'); } [/CODE] NameError: name 'web2py_component' is not defined Whether any import is required for this? I also tried {{= and {{ ---Vineet On Oct 3, 6:12 pm, juanduke juan.fu...@gmail.com wrote: Hi vineet: If I understanding what you want, my first idea to solve it is: td !-- define an A() and _onClick call a custom js function editURL(department['deptid'],department['deptnm']) -- /td then // assuming that you already defined the jquery ui dialog ( $(#deptEdt).dialog({ ... }); ) this piece of code shoul be written in jQuery(document).ready script function editURL( depId, depNm){ var urlTarget = /yourApp/yourController/yourFunctionToEditURL // here call jQuery.load or web2py_component, both recive: urlTarget and a DIV id (i.e. div id=deptEdt / jQuery(#deptEdt).load(urlTarget,{deptid:depId, depnm:depNm},function() { jQuery('#deptEdt').dialog('open'); }); //or web2py_component(urlTarget+/+depId+/+depNum, 'deptEdt'); // both way the result will be droped in #deptEdt div. You can check this with firebug or similar tool // finally show the dialog: jQuery( #deptEdt ).dialog('open');} /script I hope to be clear, and again, sorry for my bad english. The web2py_component is very usefull if you will load a form that will be submited You could read about jQuery.load [jQuery.com] and web2py_component[web2py book] functions to clarify my code HTH Bye
[web2py] Re: Modal form window
Hi Vineet: web2py_component is a javascript function, includede in web2py. So, there's no necesary to put {{ }} to call him. You can see examples of web2py_component on the book (search for LOAD function) HTH, regards.
[web2py] Re: Modal form window
Thanks juandurke. One last point is remaining in this regard. Now I can render the edit form in jquery-ui modal dialog. #Note: In the same View file, the DIV id=deptEdt is there, which is rendered in dialog form. I am passing department['deptid'] department['deptnm'] to the javascript function editURL. editURL passes these variables to a serverside function 'frmDeptEdt'. In controller mast.py def frmDeptEdt(): deptid = request.args[0] deptnm = request.args[1] return dict(deptid=deptid, deptnm=deptnm) + But I can't use deptid and deptnm in form at design-time. These variables are declared after the frmDeptEdt() function is called. I also can't use request.args[n] at design time. Only after clicking the url, these are available. It raises error name 'deptnm' not defined div id=deptEdt name=deptEdt style=display:none form enctype=multipart/form-data method=post id=frmDeptEdt name=frmDeptEdt action={{=URL(('dept_save'))}} Department input type='text' id='deptname' name='deptname' value=deptnm / input type='submit' value='save' onsubmit= / /form /div Any idea to tacke this? Thanks, Vineet On Oct 4, 9:03 pm, juanduke juan.fu...@gmail.com wrote: Hi Vineet: web2py_component is a javascript function, includede in web2py. So, there's no necesary to put {{ }} to call him. You can see examples of web2py_component on the book (search for LOAD function) HTH, regards.
[web2py] Re: Modal form window
There is one more issue. In normal case, (without overriding the click event), I could supply request.args to controller function through URL('controller', args[n1,n2,..]). In this case, since the click event is handled (overridden) by $ (#anchorname).dialog({..., how do I supply args to the jquery-ui modal form? (it is on the same view.html, called in modal form) Note: in the td element below, _onclick={{URL( in the link is overridden, so it does not work. [CODE] tbody {{for department in departments:}} tr td{{=department['deptid']}}/td td{{=department['deptnm']}}/td td {{=A('edit',_onclick={{URL('DIV on same page', args=[department['deptid'],department['deptnm']]}},_class='edturl')}} ## this {{=URL doestn't work, bcoz it is overridden in javascript {{=A('delete',_onclick={{URL('DIV on same page',args=[department['deptid'],department['deptnm']]}},_class='delurl')}} /td /tr {{pass}} /tbody $(document).ready(function() { $('.edturl').click(function(e){ $(#deptEdt).dialog({ height: 200, width:500, modal: true, show: blind, hide: explode }); }); }); [/CODE] ---vineet On Sep 30, 9:26 pm, Vineet vineet.deod...@gmail.com wrote: Oops. I overlooked that in web2py book. Thanks for pointing to it. It played the trick working OK. Now trying to use modal confirmation of jquery-ui. Thank you, :) Vineet On Sep 30, 5:43 pm, juanduke juan.fu...@gmail.com wrote: Hi Vineet: I use to get args and form's field whit *request.args(N)* (N integer = 0) and *request.vars.fieldname* (where fieldname, is a name of an input in form submited) http://www.web2py.com/book/default/docstring/request.argshttp://www.w... HTH! Bye- Hide quoted text - - Show quoted text -
[web2py] Re: Modal form window
@juanduke, Thanks, your idea worked. Just one more thing. pl. notice the form's action=. [CODE] div id=deptEdt form enctype=multipart/form-data method=post id=frmDeptEdt name=frmDeptEdt action={{=URL(('dept_save'), args=[arg1, arg2, 'I want to embed here fields from Form'])}} Department input type='text' id='deptname' name='deptname' value={{=department['deptnm']}} / input type='submit' value='save' onsubmit= / /form /div [/CODE] 'dept_save' controller saves data to DB and redirects the user to main page. Since this is a custom-designed Form (i.e. not rendered by web2py helpers), I can't use something like form.vars.fieldname 1) How do I access the contents of html elements for sending data to server? 2) After submitting the form, it is URLencoded format. How do I decode the arguments Thanks, Vineet On Sep 29, 6:48 pm, juanduke juan.fu...@gmail.com wrote: Hi Vineet: First, visit this link:http://labs.blouweb.com/PowerGrid/and click in -Docs Icons Is that the effect what you are lookin for? So, you can try doing this: on the view write an anchor A(...) with href=# the with jQuery, select this anchor, and override the click event, something like this: #Asuming the anchor having id=target $('#target').click(function(e){ alert('you click me!'); }); If you can se an alert, and no redirecting, you are doing right :) Next step is using jQuery.load function (search jquery documentation), to request an url and putting it inside a jquery dialog, then showing the dialog (here you can use nyroModal or jqueryui dialog) HTH! PS: I not tested the code Bye
[web2py] Re: Modal form window
Hi Vineet: I use to get args and form's field whit *request.args(N)* (N integer = 0) and *request.vars.fieldname* (where fieldname, is a name of an input in form submited) http://www.web2py.com/book/default/docstring/request.args http://www.web2py.com/book/default/docstring/request.vars HTH! Bye
[web2py] Re: Modal form window
Oops. I overlooked that in web2py book. Thanks for pointing to it. It played the trick working OK. Now trying to use modal confirmation of jquery-ui. Thank you, :) Vineet On Sep 30, 5:43 pm, juanduke juan.fu...@gmail.com wrote: Hi Vineet: I use to get args and form's field whit *request.args(N)* (N integer = 0) and *request.vars.fieldname* (where fieldname, is a name of an input in form submited) http://www.web2py.com/book/default/docstring/request.argshttp://www.web2py.com/book/default/docstring/request.vars HTH! Bye
[web2py] Re: Modal form window
P.S. Currently I am redirecting to a different VIEW file, and then after save, returning to the original location. I read about the ajax function in web2py. But I am looking for an 'overlay' effect. Any hint on this? ---Vineet On Sep 28, 9:44 pm, Vineet vineet.deod...@gmail.com wrote: My question is regarding displaying modal window (jquery-ui) After clicking a link in table row, the modal window appears momentarily vanishes. Code in View--- {{extend 'layout.html'}} h1Department Master/h1 table id=dept_table thead tr thDepartment ID/th thDepartment Name/th thLink/th /tr /thead tbody !--- in the code below, departments is returned from the controller --- {{for department in departments:}} tr td{{=department['deptid']}}/td td{{=department['deptnm']}}/td td{{=A('edit',_href=URL('dept_mast',args=[department['deptid'],department['deptnm']]), _onclick='$(#deptEdtFrm).dialog({height: 200,width:500,modal: true});')}}/td /tr {{pass}} /tbody /table div id=someID form id=deptEdtFrm name=deptEdtFrm method=post action= Department input type='text' id='deptnm' name='deptnm' value='{{=request.args[0]}}' / input type='submit' value='save' / /form /div -- What should I do to display the modal window without disappearing in an instant ? -Vineet
[web2py] Re: Modal form window
Hi Vineet: First, visit this link: http://labs.blouweb.com/PowerGrid/ and click in -Docs Icons Is that the effect what you are lookin for? So, you can try doing this: on the view write an anchor A(...) with href=# the with jQuery, select this anchor, and override the click event, something like this: #Asuming the anchor having id=target $('#target').click(function(e){ alert('you click me!'); }); If you can se an alert, and no redirecting, you are doing right :) Next step is using jQuery.load function (search jquery documentation), to request an url and putting it inside a jquery dialog, then showing the dialog (here you can use nyroModal or jqueryui dialog) HTH! PS: I not tested the code Bye