jijopaulose / gwtquery

Automatically exported from code.google.com/p/gwtquery
MIT License
0 stars 0 forks source link

can not get changed attribute value from event #131

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
>What steps will reproduce the problem?
in HTML there is a checkbox with default checked="checked"

in java onModuleLoad() write below:
$("#checkbox").change(new Function() {
    public boolean f(Event e) {     
    $("#test").html($(e).attr("checked") + "");             
        return true;
    }
});

>What is the expected output? What do you see instead?
The expected output is when 
checkbox checked -> display 'checked'
checkbox unchecked -> display 'undefined'
what I see is
checkbox checked -> display 'checked'
checkbox unchecked -> display 'checked'

>What version of the product are you using? On what operating system?
using gwtquery-1.1.0.jar with gwt2.40 with chrome 19.0.1084.9 in win7 32bit

Original issue reported on code.google.com by Lu.Yimin...@gmail.com on 12 Apr 2012 at 2:15

GoogleCodeExporter commented 9 years ago
It's not an issue and it's the normal behavior.

"checked" attribute defines the initial state of the checkbox (used by the 
browser to know if it has to check the checkbox when it renders it). This 
attribute doesn't reflect the state of the checkbox once it was modified by the 
user ( the browser doesn't update the attribute)

If you want to known if the checkbox is checked or not, use :
$(e).is(":checked")

Original comment by julien.d...@gmail.com on 15 Apr 2012 at 8:14

GoogleCodeExporter commented 9 years ago
Thank you for this clarification.
But I think this usage appear to be a little strange. is() is supposed to 
detect the existence of some element. What I want to do is get the attribute 
value of "checked". 
My code above work fine with jQuery but not work in Gquery in Java.
It is fine to keep these differences. But the usability was lowered by doing 
this.
since people just want to code like in jQuery.
at least I can go on with my work. Thank you.

Original comment by Lu.Yimin...@gmail.com on 19 Apr 2012 at 9:30

GoogleCodeExporter commented 9 years ago
Indeed, jQuery let the ability to the developper to know if a checkbox is 
checked or not by using the attribute 'checked'. Even, if I disagree with this 
practice, GQuery should be aligned to jQuery.
I already fix this problem when we set the attributes : 
http://code.google.com/p/gwtquery/issues/detail?id=97 But I think I have to fix 
GQuery to have the same behavior of jQuery when we get an attribute...

Original comment by julien.d...@gmail.com on 9 May 2012 at 11:05

GoogleCodeExporter commented 9 years ago
Thanks for reporting. I've migrated this issue to github : 
https://github.com/gwtquery/gwtquery/issues/163
Please follow the issue there.

Original comment by julien.d...@gmail.com on 15 Jul 2013 at 4:41

GoogleCodeExporter commented 9 years ago

Original comment by julien.d...@gmail.com on 15 Jul 2013 at 4:47