javascriptjqueryhtmlknockout.jsknockout-mapping-plugin

When radio button is clicked, element content changes to image


I can get it working for text, but can't enable it so it reads HTML for image - http://jsfiddle.net/BgQPF/

<p> Current Radiobutton Value = <span data-bind='text: selected' ></span></p>

<input type='radio' name='onlyOne' data-bind='checked: selected, enable: enable' value='<img src="https://github.com/gentoo90/minimal-django-file-upload-example/diff_blob/9ab39c7fe5abaf00f2d586e88e79a5a85075179e/src/for_django_1-3/myproject/media/documents/2012/07/12/example02.jpg?raw=true">' /> Yes
<input type='radio' name='onlyOne' data-bind='checked: selected, enable: enable' value='N' /> No
<input type='radio' name='onlyOne' data-bind='checked: selected, enable: enable' value='M' /> Maybe

Solution

  • here is the deal

    <span data-bind='html: selected' ></span>
    

    instead of

    <span data-bind='text: selected' ></span>
    

    LIVE DEMO