Quantcast
Channel: JavaScriptMVC Forum
Viewing all articles
Browse latest Browse all 3491

can.stache - Setting "readonly" attribute doesn't work

$
0
0
Hi all,

There's a (minor) bug in can.stache rendering that prevents dynamically setting the "readonly" attribute, as in
    1. <input type="text" {{#if isReadOnly}}readonly{{/if}} />
    where "isReadOnly" is a property of rendering scope. Here's a jsFiddle illustrating the issue: 
    http://jsfiddle.net/e9b64ogr/3/
    Notice that setting "disabled" works fine, but "readonly" has no effect.

    Apparently, the bug is in function set(el, attrName, val) in "can/util/attr/attr". It ends up setting el.readonly when the correct property name is el.readOnly. Writing the template attribute as "readOnly" or even "read-only" doesn't help since the first thing the function does is convert attribute name to lowercase.

    Contrast this to jQuery.prop() implementation - it uses jQuery.propFix hash that maps "readonly" to "readOnly".

    Viewing all articles
    Browse latest Browse all 3491

    Trending Articles