Re: [web2py] Re: web2py ajax function in py4web
Also, Stifan, could you post a few use cases? py4web includes vue.js by default and I am trying to understand the most common use cases of this for documentation purposes. I am guessing: - Instant form update on client side when a value is changed (for example, a star rating or even a complicated dialog) - Instant form update on client side when a database value is changed (for example, adding a line item to an invoice) Note to py4web peeps: Stifan is a gifted web2py person and I am delighted to see him posting here! -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/CALXkWBR%3DK6cuqHT-2AZSiEwWGn485Mrt7BVoDtq_TQ%2BS860oZw%40mail.gmail.com.
[web2py] Re: web2py ajax function in py4web
Stifan Can you post this in the py4web group? In py4web we don't include any jquery components. The goal is to be as light as possible and require as few additional packages as possible. I think you'll get better visibility on the py4web list to get this question answered. I know there are some javascript utilities provided with py4web but I haven't used them yet. -Jim On Saturday, November 7, 2020 at 5:16:01 PM UTC-6, 黄祥 wrote: > > > http://web2py.com/books/default/chapter/29/11/jquery-and-ajax#The-ajax-function > how to achieve this in py4web ? > > thx n best regards, > stifan > -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/8e9b3ffe-7b13-4f81-a5f0-fd40fd45b1f9o%40googlegroups.com.
[web2py] web2py ajax function in py4web
http://web2py.com/books/default/chapter/29/11/jquery-and-ajax#The-ajax-function how to achieve this in py4web ? thx n best regards, stifan -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/e243892b-4690-4580-b4f9-817ebb98a4e8n%40googlegroups.com.
[web2py] Re: web2py ajax function - checkbox form element value
the value of checkbox is either on or None *e.g.* *controllers/default.py* def callback(session_order_product): counter = int(request.vars.counter) if request.vars.action == 'adjust_factory': id = int(request.vars.id) factory = request.vars.factory if factory == 'on': factory = 'None' session_order_product[counter] = id, factory elif factory == 'None': factory = 'on' session_order_product[counter] = id, factory best regards, stifan -- 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.
[web2py] web2py ajax function - checkbox form element value
I'm using the web2py ajax function and it works fine except that the 2nd argument of the ajax function which is a list of names for the form elements includes one that is a checkbox. The ajax submission passes along the value of "on" I know that the I don't if the ajax function will accept a second argument in a different form e.g., [{'':', ...}], callbackfunction) Any help would be appreciated. I can simply use $.post in lieu of... -- 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.
[web2py] AJAX function
I've got a fairly substantial page with a lot of data in it that I don't want to keep reloading the page so I'm using the AJAX function provided with web2py and pulling the data from a SQLFORM used in the view page. Question I have is, I'm using validate_and_insert function, I was wondering is it necessary to escape the input on the server side first before the validation_and_ insert function? Thanks in advance. -- 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.
[web2py] Ajax function
Hello, this is my *view* on the *controller *I build a function containing the folowing code: pippone='ciao' stringa.append("jQuery('#paginatore').html('%s');" % pippone()) print pippone return stringa The console says ciao (the HTML generated appears to be right) When the function returns, I expect the new anchor to appear in the "paginatore" div, but it doesn't. Anybody can suggest me why? -- 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/groups/opt_out.
[web2py] ajax function is not called when passing non-ascii characters as arguments
On my page I have a set of links (page types) that loads its content dynamically when user clicks on the link. Clicking on each link calls a "LoadPage" javaScript function that calls python function that loads page content and puts it in "pageType" DIV. function LoadPage(pageType) { ajax('{{=URL("default", "ajax_LoadPage")}}' + '/' + {{=user_id}} + '/' + pageType, [], pageType); } Called ajax function users request.args[0] to retrieve pageType. if "pageType" is ascii string (i.e: "default/ajax_loadPage/1/Kalc") then page is loaded without problems. But as soon as non-ascii characters are introduced as args (i.e:"default/ajax_loadPage/1/Kalč") ajax function is not called. Is there a way to call ajax function this way and function and pass it a non-ascii argument? -- 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/groups/opt_out.
[web2py] Ajax function and returning Row, not string
I'm building a cascading dropdown lists. I use web2py ajax function to do it. My code: select 1 (parent): {{=OPTION('-- Choose department --', _value="")}} {{for d in departments:}} {{=OPTION(d.name, _value=d.id)}} {{pass}} select 2 (child): {{if request.vars.department:}} {{for r in ranks:}} {{=OPTION(r.name, _value=r.id)}} {{pass}} {{pass}} controller function: def rank(): ranks = db(db.rank.department_id == request.vars.department).select(db.rank.id, db.rank.name, orderby=db.rank.name) return ranks Ajax function calls *rank *function and passess value of the currently selected option in *department *select (parent). Then, the function assigns DAL query to *ranks *and returns it. The thing is that *ranks *is a string when returned. My for loop in the select 2 is ommited and the its example result code looks like this: "rank.idrank.name137Chief Cook138Chief Steward139Cook Assistant140Messman136Second Cook141Steward" So it LOOKS like a Row object but it's a string obvioulsy - and so I can't get any Row data out of it (r.name, r.id). Begging for help her :) -- --- 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/groups/opt_out.
[web2py] ajax function in a grid, I'm getting None in a request.vars
I'm trying to learn more about LOAD and ajax. I have an SQLFORM.grid loaded as a component. It's read only. I've added a button to each row using links = [lambda row: INPUT(_name='toggle',_type="submit",_value="Toggle", _onclick="ajax('toggle_order_import_v2',['id'] ,':eval')")]) Each row of the grid indeed has the record ID in a column called ID. The "toggle" flips a boolean field. The generated HTML looks fine: this is the button the function toggle_order_import_v2() is in my controller. it updates the database, so I want to refresh the LOADed sqlform.grid with the returned ':eval' JavaScript... I haven't got to that yet. The called function first does id = request.vars.id as preparation for updating the record matchting the grid row. but via the debugger I see that this is evaluating as None, which surprises me; I expect the ID of the row. I see there are some threads on action buttons using the A helper but I was hoping to learn how to use the ajax function, which sounds like it should work in this situation. (My legacy code does not use LOAD and the button uses a A tag; the legacy 'toggle' controller updates the database and then uses redirect to reload the page. It works, but it's slow (and worse, user filters applied to the grid are reset) When I put the SQLFORM.grid in a component but keep the legacy 'toggle' code, the redirect breaks, which is why I want to go 100% AJAX) -- --- 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/groups/opt_out.
[web2py] Re: web2py ajax function returns only non readonly fields
On Monday, July 9, 2012 11:58:45 AM UTC-4, Yuval wrote: > > To duplicate the fields once as a label and once as a hidden field? > Its doable, but not too classy, Tx. > Feel free to submit a patch. :-)
[web2py] Re: web2py ajax function returns only non readonly fields
To duplicate the fields once as a label and once as a hidden field? Its doable, but not too classy, Tx. On Monday, July 9, 2012 8:21:00 AM UTC-7, Anthony wrote: > > You might put the value in a hidden field as well. > > Anthony > > On Monday, July 9, 2012 11:09:50 AM UTC-4, Yuval wrote: >> >> The ajax function is defined as: >> ajax(url, [name1, name2, ...], target) >> >> where the 'name1' 'name2' are defined as ids of an input fields. >> *This is working fine for fields that are defined as:* >> * >> Field('first_name', label=T('First Name')) >> >> When the field is set to be read only, it is rendered as a label, and the >> value is not returned.* >> * >> Field('first_name', label=T('First Name'), default=db.auth_user. >> first_name, readable=True, writable=False), >> >> >> * >> *Is there a way to get back the value when the field is defined as read >> only?* >> >> >>
[web2py] Re: web2py ajax function returns only non readonly fields
You might put the value in a hidden field as well. Anthony On Monday, July 9, 2012 11:09:50 AM UTC-4, Yuval wrote: > > The ajax function is defined as: > ajax(url, [name1, name2, ...], target) > > where the 'name1' 'name2' are defined as ids of an input fields. > *This is working fine for fields that are defined as:* > * > Field('first_name', label=T('First Name')) > > When the field is set to be read only, it is rendered as a label, and the > value is not returned.* > * > Field('first_name', label=T('First Name'), default=db.auth_user.first_name > , readable=True, writable=False), > > > * > *Is there a way to get back the value when the field is defined as read > only?* > > >
[web2py] web2py ajax function returns only non readonly fields
The ajax function is defined as: ajax(url, [name1, name2, ...], target) where the 'name1' 'name2' are defined as ids of an input fields. *This is working fine for fields that are defined as:* * Field('first_name', label=T('First Name')) When the field is set to be read only, it is rendered as a label, and the value is not returned.* * Field('first_name', label=T('First Name'), default=db.auth_user.first_name,readable =True, writable=False), * *Is there a way to get back the value when the field is defined as read only?*
[web2py] ajax function with eval : return js function from controller
In layout.html, I have {{response.files.append(URL(r=request,c='static',f='js/xyz.js'))}} xyz.js contains a function abc(x){ code line1; code line 2; In a View, there is --> ajax('{{=URL("salhead_edit")}}, [], ':eval'); "salhead_edit" returns js function --> 'abc(myvar1)' But it is not evaluated in View. (I am sure that the js file is correctly referenced in layout.html) Note: If I directly return the "code line1; code line 2;..." from the controller, they ARE evaluated. But "function abc()" is not evaluated. Is it expected behaviour of the ajax function? Regards, Vineet
[web2py] ajax function with eval : return js function from controller
In layout.html, I have {{response.files.append(URL(r=request,c='static',f='js/xyz.js'))}} xyz.js contains a function abc(){ code line1; code line 2; In a View, there is --> ajax('{{=URL("salhead_edit")}}, [], ':eval'); "salhead_edit" returns js function --> 'abc(myvar1)' But it is not evaluated in View. (I am sure that the js file is correctly referenced in layout.html) Note: If I directly return the "code line1; code line 2;..." from the controller, they ARE evaluated. But "function abc()" is not evaluated. Is it expected behaviour of the ajax function? Regards, Vineet
[web2py] ajax function with eval : return js function from controller
In layout.html, I have {{response.files.append(URL(r=request,c='static',f='js/xyz.js'))}} xyz.js contains a function abc(){ code line1; code line 2; In a View, there is --> ajax('{{=URL("salhead_edit")}}, [], ':eval'); "salhead_edit" returns js function --> 'abc(myvar1)' But it is not evaluated in View. (I am sure that the js file is correctly referenced in layout.html) Note: If I directly return the "code line1; code line 2;..." from the controller, they ARE evaluated. But "function abc()" is not returned. Is it expected behaviour of the ajax function? Regards, Vineet
[web2py] ajax function : None returned
I was studying ajax function. Exactly reproduced the code from web2py book. =default/one.html {{extend 'layout.html'}} ==default.py=== def one(): return dict() def echo(): return request.vars.name After typing anything in the input box, "None" is displayed in the target div. Whether any correction is required in this code? Thanks, Vineet
[web2py] ajax function returns None
Hi, I have tried the example from chapter 10.3 The ajax Function Controller: def one(): return dict() def echo(): return request.vars.name one.html: {{extend 'layout.html'}} No success, because the value of request.vars.name is None Just for fun I have tried "request.now", "request.extension", "request.folder" and so on instead of "request.vars.name" - these examples worked fine, but I had no chance to get the value of name. Version: web2py 1.98.2, started from source with Windows Python 2.7.2 and web2py 1.98.2 Python 2.5 What is wrong - any ideas? Regards, Martin
[web2py] ajax function submit on script
hi, is it possible to put ajax function submit on script? e.g. jQuery(document).ready(function(){ jQuery('.view').click(function() {jQuery('.comments').slideToggle()}); jQuery('.post').click(function(){jQuery('.form').slideToggle()}); jQuery('.post').submit(function(){ajax('blog_show', 'comments hidden')}); }); i've already tried it, no error occured but the ajax function didn't work. my intention is when a user submit a comment form (using crud on controller) it will show without reloading the page, or is there any others way to do this? please give an advice and please correct me if my code is wrong. many thanks before
[web2py] ajax function
Hi, sometimes I need to use ajax function passing as second argument a list of ids and costants. There is a way to pass to callback values of elements by id, AND string costants? Thanks for help.
[web2py] ajax function target id null
Hi, I use the ajax function as follows: ajax('func1', ['id1'], '') because I don't need to send some value to the html page, so I set the third parameter null. But IE raises error 'document.getElementById(...)' is null or not an object. How can I use the ajax function when I don't want to send values to html page?
[web2py] Re: problems using web2py ajax function
Thank you Russell, your suggestion works great. I use hello! On Mar 29, 3:46 am, mdipierro wrote: > I think you can. I have not tried it. Mind that you have to ecape the > args. > > On Mar 28, 7:56 pm, Russell wrote: > > > Is there a reason not to simply place the constant in the args? > >ajax('show_month/3',[],'test') > > > or if you want to be explicit... > >ajax('show_month?month_to_show=3',[],'test') > > > On Mar 29, 4:24 am, mdipierro wrote: > > > > Normally if I want to pass a constant, I put it in a hidden field and > > > then pass the name of the hidden field. > > > > On Mar 28, 10:14 am, salbefe wrote: > > > > > Thanks, > > > > > Now is clear to me. -- You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web...@googlegroups.com. To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/web2py?hl=en.
[web2py] Re: problems using web2py ajax function
I think you can. I have not tried it. Mind that you have to ecape the args. On Mar 28, 7:56 pm, Russell wrote: > Is there a reason not to simply place the constant in the args? > ajax('show_month/3',[],'test') > > or if you want to be explicit... > ajax('show_month?month_to_show=3',[],'test') > > On Mar 29, 4:24 am, mdipierro wrote: > > > Normally if I want to pass a constant, I put it in a hidden field and > > then pass the name of the hidden field. > > > On Mar 28, 10:14 am, salbefe wrote: > > > > Thanks, > > > > Now is clear to me. -- You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web...@googlegroups.com. To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/web2py?hl=en.
[web2py] Re: problems using web2py ajax function
Is there a reason not to simply place the constant in the args? ajax('show_month/3',[],'test') or if you want to be explicit... ajax('show_month?month_to_show=3',[],'test') On Mar 29, 4:24 am, mdipierro wrote: > Normally if I want to pass a constant, I put it in a hidden field and > then pass the name of the hidden field. > > On Mar 28, 10:14 am, salbefe wrote: > > > Thanks, > > > Now is clear to me. -- You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web...@googlegroups.com. To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/web2py?hl=en.
[web2py] Re: problems using web2py ajax function
Normally if I want to pass a constant, I put it in a hidden field and then pass the name of the hidden field. On Mar 28, 10:14 am, salbefe wrote: > Thanks, > > Now is clear to me. -- You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web...@googlegroups.com. To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/web2py?hl=en.
[web2py] Re: problems using web2py ajax function
Thanks, Now is clear to me. -- You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web...@googlegroups.com. To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/web2py?hl=en.
[web2py] Re: problems using web2py ajax function
Not sure what you mean by ajax('show_month',[3],'test') the second argument of ajax had to be a list of IDs if fields. The values of those fields will be passed. On 27 Mar, 06:00, salbefe wrote: > Hello, > > With the following code: > > > {{=month_str}} span> > > > > I get the following javascript error message: > > document.getElementById(s[i]) is null > > I do not why I'm getting that error. I think this code is very similar > to the same on page 274 of the web2py book. -- You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web...@googlegroups.com. To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/web2py?hl=en.
[web2py] problems using web2py ajax function
Hello, With the following code: {{=month_str}} I get the following javascript error message: document.getElementById(s[i]) is null I do not why I'm getting that error. I think this code is very similar to the same on page 274 of the web2py book. -- You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web...@googlegroups.com. To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/web2py?hl=en.