I can modify xlink:href
through javascript and jquery just fine but modifying just the dom's xlink:href
through the knockout attr
binding does not work.
This is my svg definition
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="display:none">
<defs>
<symbol id="icon-home" viewBox="0 0 32 32">
<path class="path1" d="M32 18.451l-16-12.42-16 12.42v-5.064l16-12.42 16 12.42zM28 18v12h-8v-8h-8v8h-8v-12l12-9z"></path>
</symbol>
</defs>
This is inserted at the top of the body
Then use knockout with html and the property icon
on my view model
<svg class="svg-icon">
<use id="myuse" data-bind="attr: {'xlink:href': icon }"></use>
</svg>
I am sure icon is returning correctly because I get the following rendered output
<svg class="svg-icon">
<use data-bind="attr: {'xlink:href': icon }" xlink:href="#icon-home"></use>
</svg>
Which is correct, but nothing shows up. Does anyone have a working solution to this with knockout?