On Friday, June 1, 2012 2:03:23 PM UTC-4, angle wrote: > > Thanks for your response, I've answered your points below: > >> >> > #response.ajax = \ >>> 'web2py_component("%s","patient",ajax=True,vars=vars1)' % URL >>> ('patient') >> >> I think this should be response.js rather than response.ajax. >> > > This code is copied from the example 'Designing Modular Applications' on > page 94 of the web2py book. >
Unfortunately, I think there are a number of errors in that example, one of which is that it should be response.js, not response.ajax. > In that example it is called when a forms 'onaccept' event is triggered. > In my code it is called in my 'viewPatient' function that is called by > setting the webGrid's crud_function... (grid.crud_function = > 'viewPatient'). I thought that these were similar calls, so that > response.ajax should work in the same way. Are they not the same? ??? > In the book example, response.ajax (which should be response.js) is set in the edit_items() function, which is always called as an Ajax component. You are setting it in your view() function, but I can't see where that function is actually called, so I don't know if it is being called as an Ajax component or as a regular web page. > Also, response.js is only used if the action that sets it is being called >> as a web2py component -- is that the case here? >> > > I believe so, but I am not 100% sure. It appears that the response.ajax is > being set via a call to 'web2py_component(...)' . Is that correct? > No, you are setting response.ajax to "web2py_component(...)" -- that's not what I'm talking about. The question is whether the function in which response.js is being set is itself being accessed by a call to web2py_component() on the client side. It is being set in your view() function, so the question is how is the view() function being called? Finally, web2py_component() does not take an ajax or vars argument. If you >> want vars included in the URL, then pass it to the URL function. >> > > The URL is pointing to a div element - (as in the example from the book). > I think there is an error in the book -- it mistakenly builds a URL that refers to a div id rather than the name of the controller function. Is that what you're talking about? > I've tried 'URL('patient', vars=vars1)' (whilst assigning to response.ajax > and response.js) and I get a 'not all arguments converted during string > formatting' error. > Show the full code. Anthony