Hi guys
With live binding it seems to me that values rendered in the interface should *exactly* match those in the defining context object(s). But for null strings they don't.
A simple mustache template
<script id="template" type="text/mustache">
{{#each options}}
<label><input type="checkbox" name="{{name}}" value="{{value}}">{{label}}</label>
{{/each}}
</script>
with a simple context
var data = {
options = [
{ name: 'field1', label" 'label1', value: '' },
{ name: 'field2', label" 'label2', value: '111' },
{ name: 'field3', label" 'label3', value: '222' }
];
};
var obs = new can.Observe(data);
when rendered with
$('#myDiv').append(can.view('template', obs.data));
will visually render correctly BUT
Checking the browser debugger this renders as (in Chrome) <label><input name="field1" value> ...
I am expecting value='' which is *very* different.
So the javascript value is undefined which does not match the cnsjs observable value which is null, For all non-null instances it's OK.
Not an absolute train smash as I *could* test for undefined as well as null if I had to ... *but* ...
Am I doing something wrong ? Is this a bug ?? Or maybe it's a feature ???
Enquiring minds would like to know.
Ron
With live binding it seems to me that values rendered in the interface should *exactly* match those in the defining context object(s). But for null strings they don't.
A simple mustache template
<script id="template" type="text/mustache">
{{#each options}}
<label><input type="checkbox" name="{{name}}" value="{{value}}">{{label}}</label>
{{/each}}
</script>
with a simple context
var data = {
options = [
{ name: 'field1', label" 'label1', value: '' },
{ name: 'field2', label" 'label2', value: '111' },
{ name: 'field3', label" 'label3', value: '222' }
];
};
var obs = new can.Observe(data);
when rendered with
$('#myDiv').append(can.view('template', obs.data));
will visually render correctly BUT
Checking the browser debugger this renders as (in Chrome) <label><input name="field1" value> ...
I am expecting value='' which is *very* different.
So the javascript value is undefined which does not match the cnsjs observable value which is null, For all non-null instances it's OK.
Not an absolute train smash as I *could* test for undefined as well as null if I had to ... *but* ...
Am I doing something wrong ? Is this a bug ?? Or maybe it's a feature ???
Enquiring minds would like to know.
Ron