3.2.0

Removing attributes from an HTML Object

Is there a way to remove an attribute from an HTML object.

I am still working on the checkbox thing. My direct problem is that when the "checked" property is set on an HTML input element, the checkbox always displays as checked (unless I missed something).

eg rendered code:

<input type="checkbox" name="foo" value="bar" checked="false|OFF"/>


still displays as a checked box.

So, is there a way in the object create function to say something along the lines of

if (this.getItemProperty("text")==mycheckedValue) {
    obj.setAttribute("checked","true");
}


so that the attribute is only set if the checkbox should be checked?


Also is there a way to have the attribute be removed? (eg when the checkbox is unchecked, and the html.refresh() is called the input is not rendered as checked)

I suppose I could manipulate the htmlObj._attributes property, but that is kind of hackish.

Or if this could be solved with some fundametal HTML knowledge, that would be even better.

Thanks


gbegley
May 10,
I am going to publish a new release (0.3.2) in the next couple of days, which fixes the problem with attributes like CHECKED, DISABLED, READONLY. The null value will completely remove an attribute from HTML string.
Alex (ActiveWidgets)
May 10,
Thanks, That will be great.

Currently,
I have

obj.setAttribute("checked", function(){ return shouldBeChecked?"true":null; }

which gives me alert code of

<input type="checkbox" name="foo" value="bar" checked="null"/>


I suspect this is because a function returning null isn't the same as null itself.

I will eagerly await the 0.3.2 release.


If I haven't said so this week, this project is awsome!
gbegley
May 10,
The new 0.3.2 release is available now. It should allow clear checkbox with either false or null values in checked attribute.
Alex (ActiveWidgets)
May 11,
Great!, thanks for implementing this so quickly.
gbegley
May 11,
Thanks Alex, that works perfectly
gbegley
May 11,

This topic is archived.

See also:


Back to support forum