[web2py] Re: Checkbox ajax not updating request.vars -- bug or pilot error?

2010-12-04 Thread mr.freeze
The var name should just be 'junk' since that is the name of the
checkbox. Also, I don't think you should have a closing parenthesis
after _id='no_table_junk'. Just a typo? Also, accessing it like
request.vars['no_table_junk'] will throw an error. Why not just use
request.vars.xxx and check for None? Also, it will not have a value of
'off' when unchecked, request.vars will just be empty. This works for
me:

def checktest():
div=DIV(_id='test')
inp = INPUT(_type='checkbox',
_name='junk',
_id='no_table_junk',
_onclick=ajax('process_checkbox',
['no_table_junk'],':eval');)
return dict(div=div,inp=inp)

def process_checkbox():
  checkbox_results=request.vars.junk
  return jQuery(#test).html(%s); % checkbox_results




On Dec 4, 12:57 pm, weheh richard_gor...@verizon.net wrote:
 I have a form with a dummy checkbox:

 #view
 INPUT(_type='checkbox',_name='junk',_id='no_table_junk'),
         _onclick=ajax('process_checkbox',
 ['no_table_junk'],':eval');)

 #controller
 def process_checkbox():
   checkbox_results=request.vars['no_table_junk']
   return jQuery(#test).html(%s); % checkbox_results

 Regardless of whether the checkbox is checked or not, the onclick
 event passes to the process_checkbox routine a
 request.vars['no_table_junk'] equal to 'on'. I would have expected it
 to toggle from on to off to on again as I keep toggling the
 checkbox from checked to unchecked.

 Anybody know what's wrong?


[web2py] Re: Checkbox ajax not updating request.vars -- bug or pilot error?

2010-12-04 Thread weheh
Hi Nathan, thanks for the response. I checked the old threads (like
this one
http://groups.google.com/group/web2py/browse_thread/thread/35c5708111d173ae/7d12923e4643a3ed?lnk=gstq=ajax+checkbox#7d12923e4643a3ed)
and see this is an old issue. In fact, I complained of this a long
time ago in a separate post. I'll try your fix and report back.

On Dec 4, 2:14 pm, mr.freeze nat...@freezable.com wrote:
 The var name should just be 'junk' since that is the name of the
 checkbox. Also, I don't think you should have a closing parenthesis
 after _id='no_table_junk'. Just a typo? Also, accessing it like
 request.vars['no_table_junk'] will throw an error. Why not just use
 request.vars.xxx and check for None? Also, it will not have a value of
 'off' when unchecked, request.vars will just be empty. This works for
 me:

 def checktest():
     div=DIV(_id='test')
     inp = INPUT(_type='checkbox',
                 _name='junk',
                 _id='no_table_junk',
                 _onclick=ajax('process_checkbox',
 ['no_table_junk'],':eval');)
     return dict(div=div,inp=inp)

 def process_checkbox():
   checkbox_results=request.vars.junk
   return jQuery(#test).html(%s); % checkbox_results

 On Dec 4, 12:57 pm, weheh richard_gor...@verizon.net wrote:

  I have a form with a dummy checkbox:

  #view
  INPUT(_type='checkbox',_name='junk',_id='no_table_junk'),
          _onclick=ajax('process_checkbox',
  ['no_table_junk'],':eval');)

  #controller
  def process_checkbox():
    checkbox_results=request.vars['no_table_junk']
    return jQuery(#test).html(%s); % checkbox_results

  Regardless of whether the checkbox is checked or not, the onclick
  event passes to the process_checkbox routine a
  request.vars['no_table_junk'] equal to 'on'. I would have expected it
  to toggle from on to off to on again as I keep toggling the
  checkbox from checked to unchecked.

  Anybody know what's wrong?




[web2py] Re: Checkbox ajax not updating request.vars -- bug or pilot error?

2010-12-04 Thread weheh
So I tried Nathan's suggested test case above and the return value of
request.vars.junk is always None, regardless of whether the checkbox
is checked or not. I'm not seeing the case where request.vars is empty
when the checkbox is unchecked. In a nutshell, unless I'm doing
something wrong, it's not working. I'm using web2py version 1.89.5.

On Dec 4, 2:22 pm, weheh richard_gor...@verizon.net wrote:
 Hi Nathan, thanks for the response. I checked the old threads (like
 this 
 onehttp://groups.google.com/group/web2py/browse_thread/thread/35c5708111...)
 and see this is an old issue. In fact, I complained of this a long
 time ago in a separate post. I'll try your fix and report back.

 On Dec 4, 2:14 pm, mr.freeze nat...@freezable.com wrote:

  The var name should just be 'junk' since that is the name of the
  checkbox. Also, I don't think you should have a closing parenthesis
  after _id='no_table_junk'. Just a typo? Also, accessing it like
  request.vars['no_table_junk'] will throw an error. Why not just use
  request.vars.xxx and check for None? Also, it will not have a value of
  'off' when unchecked, request.vars will just be empty. This works for
  me:

  def checktest():
      div=DIV(_id='test')
      inp = INPUT(_type='checkbox',
                  _name='junk',
                  _id='no_table_junk',
                  _onclick=ajax('process_checkbox',
  ['no_table_junk'],':eval');)
      return dict(div=div,inp=inp)

  def process_checkbox():
    checkbox_results=request.vars.junk
    return jQuery(#test).html(%s); % checkbox_results

  On Dec 4, 12:57 pm, weheh richard_gor...@verizon.net wrote:

   I have a form with a dummy checkbox:

   #view
   INPUT(_type='checkbox',_name='junk',_id='no_table_junk'),
           _onclick=ajax('process_checkbox',
   ['no_table_junk'],':eval');)

   #controller
   def process_checkbox():
     checkbox_results=request.vars['no_table_junk']
     return jQuery(#test).html(%s); % checkbox_results

   Regardless of whether the checkbox is checked or not, the onclick
   event passes to the process_checkbox routine a
   request.vars['no_table_junk'] equal to 'on'. I would have expected it
   to toggle from on to off to on again as I keep toggling the
   checkbox from checked to unchecked.

   Anybody know what's wrong?




[web2py] Re: Checkbox ajax not updating request.vars -- bug or pilot error?

2010-12-04 Thread mr.freeze
Strange. Works on my system. Have you modified the ajax function in
web2py_ajax.html?

On Dec 4, 1:56 pm, weheh richard_gor...@verizon.net wrote:
 So I tried Nathan's suggested test case above and the return value of
 request.vars.junk is always None, regardless of whether the checkbox
 is checked or not. I'm not seeing the case where request.vars is empty
 when the checkbox is unchecked. In a nutshell, unless I'm doing
 something wrong, it's not working. I'm using web2py version 1.89.5.

 On Dec 4, 2:22 pm, weheh richard_gor...@verizon.net wrote:

  Hi Nathan, thanks for the response. I checked the old threads (like
  this 
  onehttp://groups.google.com/group/web2py/browse_thread/thread/35c5708111...)
  and see this is an old issue. In fact, I complained of this a long
  time ago in a separate post. I'll try your fix and report back.

  On Dec 4, 2:14 pm, mr.freeze nat...@freezable.com wrote:

   The var name should just be 'junk' since that is the name of the
   checkbox. Also, I don't think you should have a closing parenthesis
   after _id='no_table_junk'. Just a typo? Also, accessing it like
   request.vars['no_table_junk'] will throw an error. Why not just use
   request.vars.xxx and check for None? Also, it will not have a value of
   'off' when unchecked, request.vars will just be empty. This works for
   me:

   def checktest():
       div=DIV(_id='test')
       inp = INPUT(_type='checkbox',
                   _name='junk',
                   _id='no_table_junk',
                   _onclick=ajax('process_checkbox',
   ['no_table_junk'],':eval');)
       return dict(div=div,inp=inp)

   def process_checkbox():
     checkbox_results=request.vars.junk
     return jQuery(#test).html(%s); % checkbox_results

   On Dec 4, 12:57 pm, weheh richard_gor...@verizon.net wrote:

I have a form with a dummy checkbox:

#view
INPUT(_type='checkbox',_name='junk',_id='no_table_junk'),
        _onclick=ajax('process_checkbox',
['no_table_junk'],':eval');)

#controller
def process_checkbox():
  checkbox_results=request.vars['no_table_junk']
  return jQuery(#test).html(%s); % checkbox_results

Regardless of whether the checkbox is checked or not, the onclick
event passes to the process_checkbox routine a
request.vars['no_table_junk'] equal to 'on'. I would have expected it
to toggle from on to off to on again as I keep toggling the
checkbox from checked to unchecked.

Anybody know what's wrong?




[web2py] Re: Checkbox ajax not updating request.vars -- bug or pilot error?

2010-12-04 Thread weheh
No. web2py_ajax.html is the original

On Dec 4, 3:59 pm, mr.freeze nat...@freezable.com wrote:
 Strange. Works on my system. Have you modified the ajax function in
 web2py_ajax.html?

 On Dec 4, 1:56 pm, weheh richard_gor...@verizon.net wrote:

  So I tried Nathan's suggested test case above and the return value of
  request.vars.junk is always None, regardless of whether the checkbox
  is checked or not. I'm not seeing the case where request.vars is empty
  when the checkbox is unchecked. In a nutshell, unless I'm doing
  something wrong, it's not working. I'm using web2py version 1.89.5.

  On Dec 4, 2:22 pm, weheh richard_gor...@verizon.net wrote:

   Hi Nathan, thanks for the response. I checked the old threads (like
   this 
   onehttp://groups.google.com/group/web2py/browse_thread/thread/35c5708111...)
   and see this is an old issue. In fact, I complained of this a long
   time ago in a separate post. I'll try your fix and report back.

   On Dec 4, 2:14 pm, mr.freeze nat...@freezable.com wrote:

The var name should just be 'junk' since that is the name of the
checkbox. Also, I don't think you should have a closing parenthesis
after _id='no_table_junk'. Just a typo? Also, accessing it like
request.vars['no_table_junk'] will throw an error. Why not just use
request.vars.xxx and check for None? Also, it will not have a value of
'off' when unchecked, request.vars will just be empty. This works for
me:

def checktest():
    div=DIV(_id='test')
    inp = INPUT(_type='checkbox',
                _name='junk',
                _id='no_table_junk',
                _onclick=ajax('process_checkbox',
['no_table_junk'],':eval');)
    return dict(div=div,inp=inp)

def process_checkbox():
  checkbox_results=request.vars.junk
  return jQuery(#test).html(%s); % checkbox_results

On Dec 4, 12:57 pm, weheh richard_gor...@verizon.net wrote:

 I have a form with a dummy checkbox:

 #view
 INPUT(_type='checkbox',_name='junk',_id='no_table_junk'),
         _onclick=ajax('process_checkbox',
 ['no_table_junk'],':eval');)

 #controller
 def process_checkbox():
   checkbox_results=request.vars['no_table_junk']
   return jQuery(#test).html(%s); % checkbox_results

 Regardless of whether the checkbox is checked or not, the onclick
 event passes to the process_checkbox routine a
 request.vars['no_table_junk'] equal to 'on'. I would have expected it
 to toggle from on to off to on again as I keep toggling the
 checkbox from checked to unchecked.

 Anybody know what's wrong?




[web2py] Re: Checkbox ajax not updating request.vars -- bug or pilot error?

2010-12-04 Thread mr.freeze
Feel free to send me a packed app to test on my system.

On Dec 4, 3:13 pm, weheh richard_gor...@verizon.net wrote:
 No. web2py_ajax.html is the original

 On Dec 4, 3:59 pm, mr.freeze nat...@freezable.com wrote:

  Strange. Works on my system. Have you modified the ajax function in
  web2py_ajax.html?

  On Dec 4, 1:56 pm, weheh richard_gor...@verizon.net wrote:

   So I tried Nathan's suggested test case above and the return value of
   request.vars.junk is always None, regardless of whether the checkbox
   is checked or not. I'm not seeing the case where request.vars is empty
   when the checkbox is unchecked. In a nutshell, unless I'm doing
   something wrong, it's not working. I'm using web2py version 1.89.5.

   On Dec 4, 2:22 pm, weheh richard_gor...@verizon.net wrote:

Hi Nathan, thanks for the response. I checked the old threads (like
this 
onehttp://groups.google.com/group/web2py/browse_thread/thread/35c5708111...)
and see this is an old issue. In fact, I complained of this a long
time ago in a separate post. I'll try your fix and report back.

On Dec 4, 2:14 pm, mr.freeze nat...@freezable.com wrote:

 The var name should just be 'junk' since that is the name of the
 checkbox. Also, I don't think you should have a closing parenthesis
 after _id='no_table_junk'. Just a typo? Also, accessing it like
 request.vars['no_table_junk'] will throw an error. Why not just use
 request.vars.xxx and check for None? Also, it will not have a value of
 'off' when unchecked, request.vars will just be empty. This works for
 me:

 def checktest():
     div=DIV(_id='test')
     inp = INPUT(_type='checkbox',
                 _name='junk',
                 _id='no_table_junk',
                 _onclick=ajax('process_checkbox',
 ['no_table_junk'],':eval');)
     return dict(div=div,inp=inp)

 def process_checkbox():
   checkbox_results=request.vars.junk
   return jQuery(#test).html(%s); % checkbox_results

 On Dec 4, 12:57 pm, weheh richard_gor...@verizon.net wrote:

  I have a form with a dummy checkbox:

  #view
  INPUT(_type='checkbox',_name='junk',_id='no_table_junk'),
          _onclick=ajax('process_checkbox',
  ['no_table_junk'],':eval');)

  #controller
  def process_checkbox():
    checkbox_results=request.vars['no_table_junk']
    return jQuery(#test).html(%s); % checkbox_results

  Regardless of whether the checkbox is checked or not, the onclick
  event passes to the process_checkbox routine a
  request.vars['no_table_junk'] equal to 'on'. I would have expected 
  it
  to toggle from on to off to on again as I keep toggling the
  checkbox from checked to unchecked.

  Anybody know what's wrong?




[web2py] Re: Checkbox ajax not updating request.vars -- bug or pilot error?

2010-12-04 Thread weheh
On close inspection, web2py_ajax.html is out of date on my test app. I
updated web2py_ajax.html and the test case still doesn't work.


[web2py] Re: Checkbox ajax not updating request.vars -- bug or pilot error?

2010-12-04 Thread mr.freeze
Your web2py_ajax.html ajax function IS different. Note this line:
Yours:
 q = jQuery([name=+s[i]+]).serialize();
Standard:
 q = jQuery(#+s[i]).serialize();

On Dec 4, 3:32 pm, weheh richard_gor...@verizon.net wrote:
 On close inspection, web2py_ajax.html is out of date on my test app. I
 updated web2py_ajax.html and the test case still doesn't work.


[web2py] Re: Checkbox ajax not updating request.vars -- bug or pilot error?

2010-12-04 Thread mr.freeze
Perhaps this was a recent change in trunk but it's definitely not
backwards compatible.  Selecting by name and id will definitely give
you different results.

On Dec 4, 4:14 pm, mr.freeze nat...@freezable.com wrote:
 Your web2py_ajax.html ajax function IS different. Note this line:
 Yours:
  q = jQuery([name=+s[i]+]).serialize();
 Standard:
  q = jQuery(#+s[i]).serialize();

 On Dec 4, 3:32 pm, weheh richard_gor...@verizon.net wrote:

  On close inspection, web2py_ajax.html is out of date on my test app. I
  updated web2py_ajax.html and the test case still doesn't work.




[web2py] Re: Checkbox ajax not updating request.vars -- bug or pilot error?

2010-12-04 Thread mr.freeze
Yep, changed on 11/3. Maybe web2py_ajax.html doesn't fall under the
same backwards compatibility umbrella as the actual framework. Anyway,
it's selecting by name so just change your onclick to:
 _onclick=ajax('process_checkbox',['junk'],':eval');)
...and it should work.

On Dec 4, 4:17 pm, mr.freeze nat...@freezable.com wrote:
 Perhaps this was a recent change in trunk but it's definitely not
 backwards compatible.  Selecting by name and id will definitely give
 you different results.

 On Dec 4, 4:14 pm, mr.freeze nat...@freezable.com wrote:

  Your web2py_ajax.html ajax function IS different. Note this line:
  Yours:
   q = jQuery([name=+s[i]+]).serialize();
  Standard:
   q = jQuery(#+s[i]).serialize();

  On Dec 4, 3:32 pm, weheh richard_gor...@verizon.net wrote:

   On close inspection, web2py_ajax.html is out of date on my test app. I
   updated web2py_ajax.html and the test case still doesn't work.




Re: [web2py] Re: Checkbox ajax not updating request.vars -- bug or pilot error?

2010-12-04 Thread Jonathan Lundell
On Dec 4, 2010, at 2:26 PM, mr.freeze wrote:
 
 Yep, changed on 11/3. Maybe web2py_ajax.html doesn't fall under the
 same backwards compatibility umbrella as the actual framework. Anyway,
 it's selecting by name so just change your onclick to:
 _onclick=ajax('process_checkbox',['junk'],':eval');)
 ...and it should work.

In general, the stuff under applications/ doesn't fall under backwards 
compatibility, since it won't change once you've incorporated it into your own 
app, unless and until you want to change it, either by doing your own edits or 
by incorporating a later version. 

[web2py] Re: Checkbox ajax not updating request.vars -- bug or pilot error?

2010-12-04 Thread weheh
OK, that did the trick. Thanks.

As for the web2py_ajax.html file, all I have to say is, 'Urggh!' This
is probably the 3rd time I've been bitten by changes to the file in
the last year or two. Must keep that in mind in the future.

Again, many thanks for the help, Nathan. You too, Jonathan.


On Dec 4, 5:26 pm, mr.freeze nat...@freezable.com wrote:
 Yep, changed on 11/3. Maybe web2py_ajax.html doesn't fall under the
 same backwards compatibility umbrella as the actual framework. Anyway,
 it's selecting by name so just change your onclick to:
  _onclick=ajax('process_checkbox',['junk'],':eval');)
 ...and it should work.

 On Dec 4, 4:17 pm, mr.freeze nat...@freezable.com wrote:

  Perhaps this was a recent change in trunk but it's definitely not
  backwards compatible.  Selecting by name and id will definitely give
  you different results.

  On Dec 4, 4:14 pm, mr.freeze nat...@freezable.com wrote:

   Your web2py_ajax.html ajax function IS different. Note this line:
   Yours:
    q = jQuery([name=+s[i]+]).serialize();
   Standard:
    q = jQuery(#+s[i]).serialize();

   On Dec 4, 3:32 pm, weheh richard_gor...@verizon.net wrote:

On close inspection, web2py_ajax.html is out of date on my test app. I
updated web2py_ajax.html and the test case still doesn't work.




Re: [web2py] Re: Checkbox ajax not updating request.vars -- bug or pilot error?

2010-12-04 Thread Jonathan Lundell
On Dec 4, 2010, at 2:53 PM, weheh wrote:
 
 OK, that did the trick. Thanks.
 
 As for the web2py_ajax.html file, all I have to say is, 'Urggh!' This
 is probably the 3rd time I've been bitten by changes to the file in
 the last year or two. Must keep that in mind in the future.

Right; you can't count on being able to simply copy it over to your application 
when it changes.

I've been doing this (a little tedious, but necessary). I make a copy of the 
stock web2py_ajax.html file (this could happen with other application files as 
well; layout.html in my case) to keep as a reference, and then make my own 
local changes to it (typically not a lot, but some).

When I'm motivated to incorporate a newer version, I diff the original stock 
file against the new one, to see what the web2py changes are, and diff the 
original stock file against my current file, to see what I did. Then I apply my 
changes to the new stock version (keeping a reference copy, of course), and 
also evaluate whether the changes to the web2py version have any implications 
for my app, and deal with them.

I could probably enlist hg to help with this process, but so far I've been 
doing it manually; I find it a little less confusing. You're basically merging 
two parallel branches, and sometimes it's hard to do that mechanically.

 
 Again, many thanks for the help, Nathan. You too, Jonathan.
 
 
 On Dec 4, 5:26 pm, mr.freeze nat...@freezable.com wrote:
 Yep, changed on 11/3. Maybe web2py_ajax.html doesn't fall under the
 same backwards compatibility umbrella as the actual framework. Anyway,
 it's selecting by name so just change your onclick to:
  _onclick=ajax('process_checkbox',['junk'],':eval');)
 ...and it should work.
 
 On Dec 4, 4:17 pm, mr.freeze nat...@freezable.com wrote:
 
 Perhaps this was a recent change in trunk but it's definitely not
 backwards compatible.  Selecting by name and id will definitely give
 you different results.
 
 On Dec 4, 4:14 pm, mr.freeze nat...@freezable.com wrote:
 
 Your web2py_ajax.html ajax function IS different. Note this line:
 Yours:
  q = jQuery([name=+s[i]+]).serialize();
 Standard:
  q = jQuery(#+s[i]).serialize();
 
 On Dec 4, 3:32 pm, weheh richard_gor...@verizon.net wrote:
 
 On close inspection, web2py_ajax.html is out of date on my test app. I
 updated web2py_ajax.html and the test case still doesn't work.
 
 




[web2py] Re: Checkbox ajax not updating request.vars -- bug or pilot error? [Closed (but not entirely resolved)]

2010-12-04 Thread weheh
On further consideration, I consider this a kludge, albeit one that
I'm at a loss to figure out how to fix. The web2py way is web2py
+jQuery+ajax+css+... (hope I didn't leave something out). In the
interest of backwards compatibility, we need to think carefully about
this web2py_ajax.html file and how it gets updated. For instance, the
new web2py_ajax.html file and ajax-ing approach seem to be passing
variables by the name of the widget referenced by the event, not by
its id. In the past, it was id only. This is a rather substantial
change that I seem to have missed in the forum threads (I was out of
town for a few weeks) and also is missing in the doc. Beating my head
on this wall effectively wasted me a day. I've got to believe there's
a better way.

Nevertheless, I'm closing this thread because my underlying issue is
resolved. But I'm carrying scars from the experience.



On Dec 4, 6:23 pm, Jonathan Lundell jlund...@pobox.com wrote:
 On Dec 4, 2010, at 2:53 PM, weheh wrote:



  OK, that did the trick. Thanks.

  As for the web2py_ajax.html file, all I have to say is, 'Urggh!' This
  is probably the 3rd time I've been bitten by changes to the file in
  the last year or two. Must keep that in mind in the future.

 Right; you can't count on being able to simply copy it over to your 
 application when it changes.

 I've been doing this (a little tedious, but necessary). I make a copy of the 
 stock web2py_ajax.html file (this could happen with other application files 
 as well; layout.html in my case) to keep as a reference, and then make my own 
 local changes to it (typically not a lot, but some).

 When I'm motivated to incorporate a newer version, I diff the original stock 
 file against the new one, to see what the web2py changes are, and diff the 
 original stock file against my current file, to see what I did. Then I apply 
 my changes to the new stock version (keeping a reference copy, of course), 
 and also evaluate whether the changes to the web2py version have any 
 implications for my app, and deal with them.

 I could probably enlist hg to help with this process, but so far I've been 
 doing it manually; I find it a little less confusing. You're basically 
 merging two parallel branches, and sometimes it's hard to do that 
 mechanically.



  Again, many thanks for the help, Nathan. You too, Jonathan.

  On Dec 4, 5:26 pm, mr.freeze nat...@freezable.com wrote:
  Yep, changed on 11/3. Maybe web2py_ajax.html doesn't fall under the
  same backwards compatibility umbrella as the actual framework. Anyway,
  it's selecting by name so just change your onclick to:
   _onclick=ajax('process_checkbox',['junk'],':eval');)
  ...and it should work.

  On Dec 4, 4:17 pm, mr.freeze nat...@freezable.com wrote:

  Perhaps this was a recent change in trunk but it's definitely not
  backwards compatible.  Selecting by name and id will definitely give
  you different results.

  On Dec 4, 4:14 pm, mr.freeze nat...@freezable.com wrote:

  Your web2py_ajax.html ajax function IS different. Note this line:
  Yours:
   q = jQuery([name=+s[i]+]).serialize();
  Standard:
   q = jQuery(#+s[i]).serialize();

  On Dec 4, 3:32 pm, weheh richard_gor...@verizon.net wrote:

  On close inspection, web2py_ajax.html is out of date on my test app. I
  updated web2py_ajax.html and the test case still doesn't work.