Thank you. I am grateful for all your help. Simon
On Wednesday, 7 November 2012 22:43:32 UTC, Niphlod wrote: > > whoops, actually, the book needs a fix on that. > now it's redirect with client_side=True > > On Wednesday, November 7, 2012 11:40:47 PM UTC+1, Niphlod wrote: >> >> sounds like premature optimization / I don't want to use a LOAD :P >> did you try redirecting after the form with type='auto' ? (I think that >> that's a feature available in the last few releases...) >> >> On Wednesday, November 7, 2012 11:31:09 PM UTC+1, Simon Carr wrote: >>> >>> I want it to be loaded with AJAX and submitted normally. The reason is >>> two fold. >>> >>> 1. The page needs to be refreshed after the form is submitted. >>> 2. By loading the form by AJAX and Submitting normally I am at least >>> cutting full page loads down by 50% >>> >>> On Wednesday, 7 November 2012 21:41:23 UTC, Niphlod wrote: >>>> >>>> I'm loosing you (too much asked, too little information). >>>> - you have a page -->done >>>> - you want a form loaded into a page --> done >>>> - you want it to be submitted to the url that is loaded from --> done >>>> (if it's loaded through ajax, that means that you don't want to reload the >>>> main page, so it can't be submitted with anything else) >>>> >>>> now what ? >>>> >>>> On Wednesday, November 7, 2012 10:34:48 PM UTC+1, Simon Carr wrote: >>>>> >>>>> Your right. Thanks mate. I was getting confused over cid. But anyway >>>>> it works great for creating the form. >>>>> >>>>> I notice that the form also submits via AJAX. How do I make it submit >>>>> normally so that I can have the page refreshed? I need the users list of >>>>> subscribed Charts and some other details to be updated after submitting >>>>> the >>>>> form. >>>>> >>>>> Thanks >>>>> Simon >>>>> >>>>> On Wednesday, 7 November 2012 21:04:35 UTC, Niphlod wrote: >>>>>> >>>>>> doesn't it already (provided that there is a <div >>>>>> id='whatever'></div> in the page) ? >>>>>> >>>>>> On Wednesday, November 7, 2012 9:36:27 PM UTC+1, Simon Carr wrote: >>>>>>> >>>>>>> Thank you, but how do I implement this in my view so that it loads >>>>>>> the form into a div when the link is clicked? >>>>>>> >>>>>>> On Wednesday, 7 November 2012 20:00:52 UTC, Niphlod wrote: >>>>>>>> >>>>>>>> Wait a sec. callback and target are meant to load a fragment via >>>>>>>> ajax, but that doesn't "fire" all the logic needed to intercept FORMs >>>>>>>> etc. >>>>>>>> _callback and _target are meant roughly as an "onclick" under >>>>>>>> steroids. (under the hood it translates to an onclick="ajax(url, >>>>>>>> target)") >>>>>>>> >>>>>>>> What you're trying to achieve is probably offered by the LOAD >>>>>>>> helper, that can be exploited in an A() using _href and cid >>>>>>>> >>>>>>>> A('Add to My Charts',_href=URL('subscribe_form',vars={'chartname': >>>>>>>> 'whatever'}), cid='whatever') >>>>>>>> >>>>>>>> That will load the component and trap all links and form >>>>>>>> submissions, because it translates to an >>>>>>>> onclick="web2py_component(url, >>>>>>>> target)" >>>>>>>> >>>>>>>> >>>>>>>> On Wednesday, November 7, 2012 8:39:50 PM UTC+1, Simon Carr wrote: >>>>>>>>> >>>>>>>>> The URL with the form in >>>>>>>>> is web2py_xlchart_dashboard/charts/user_charts so without an action >>>>>>>>> it will >>>>>>>>> submit to *user_charts*, but I need it to submit to*subscribe_form >>>>>>>>> *which is the function that was called by AJAX to generate the >>>>>>>>> Form. >>>>>>>>> >>>>>>>>> or am I not understanding something? >>>>>>>>> >>>>>>>>> Simon >>>>>>>>> >>>>>>>>> On Wednesday, 7 November 2012 19:26:46 UTC, Derek wrote: >>>>>>>>>> >>>>>>>>>> Why would you need to create an action for the form? Are you not >>>>>>>>>> using self submit? >>>>>>>>>> >>>>>>>>>> On Wednesday, November 7, 2012 12:22:03 PM UTC-7, Simon Carr >>>>>>>>>> wrote: >>>>>>>>>>> >>>>>>>>>>> I have this piece of code that calls a function in my controller >>>>>>>>>>> when clicked. >>>>>>>>>>> >>>>>>>>>>> {{=A('Add to My Charts',callback=URL('subscribe_form',vars={ >>>>>>>>>>> 'chartname':chart.chartName}),target=str(chart.chartName). >>>>>>>>>>> replace('.','_'))}} >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> The subscribe_form function looks like this >>>>>>>>>>> >>>>>>>>>>> def subscribe_form(): >>>>>>>>>>> >>>>>>>>>>> form = >>>>>>>>>>> SQLFORM(db.user_chart,fields=['title','description'],hidden=dict(chartname=request.vars['chartname'])) >>>>>>>>>>> if form.process().accepted: >>>>>>>>>>> response.flash = 'form accepted' >>>>>>>>>>> elif form.errors: >>>>>>>>>>> response.flash = 'form has errors' >>>>>>>>>>> else: >>>>>>>>>>> response.flash = 'please fill out the form' >>>>>>>>>>> return form >>>>>>>>>>> >>>>>>>>>>> The Form is created by AJAX, but it's action is blank. >>>>>>>>>>> >>>>>>>>>>> Do I have to specify the action myself if I am build a Form via >>>>>>>>>>> AJAX? >>>>>>>>>>> >>>>>>>>>>> Simon >>>>>>>>>>> >>>>>>>>>> --