BorisMoore / jsviews

Interactive data-driven views, MVVM and MVP, built on top of JsRender templates
http://www.jsviews.com/#jsviews
MIT License
856 stars 130 forks source link

Checkbox group support #426

Closed BorisMoore closed 4 years ago

BorisMoore commented 5 years ago

For context, see: https://github.com/BorisMoore/jsrender/issues/350, from @wklau2006

hkvstore commented 5 years ago

Thank you for providing support for this.

BorisMoore commented 5 years ago

I have an update ready that includes new checkbox group support, including a {{checkboxgroup}} tag (similar to {{radiogroup}}. However I will be travelling for the next three weeks, and unfortunately did not quite have enough time to complete testing and committing the new version (1.0.4). I expect to do so in the first week of July.

Here is my current code you can test (but with the update I will also provide new docs for checkbox groups, so you may want to wait...).

jsviews1.0.4d.js.txt

hkvstore commented 5 years ago

Thanks. It works.

Tested with:

<div id="result"></div>

<script id="tmpl" type="text/x-jsrender">
    {^{checkboxgroup selectedCar}}
    <label><input type="checkbox" value="none"/>
        None</label><br/>
    <label><input type="checkbox" value="volvo"/>
        Volvo</label><br/>
    <label><input type="checkbox" value="ford"/>
        Ford</label><br/>
    {{/checkboxgroup}}

    <span class="spanbox" data-link="selectedCar||'none'"></span>
</script>

<script>
var tmpl = $.templates("#tmpl");
var data = {selectedCar: ["ford","volvo"]};
tmpl.link("#result", data);
</script>
BorisMoore commented 4 years ago

This feature has been added in v1.0.4 - see https://www.jsviews.com/#jsvcheckboxgrouptag