Search code examples
javascriptrazorknockout.js

How to I add space in data-bind"text:..."?


I'm trying to add space between file names in a div. It looks like this

<span class="upload-bar__file-name" data-bind="text: name"></span>

I tried this but didn't work

<span class="upload-bar__file-name" data-bind="text: ' ' + name"></span>

EDIT: I'm trying to accomplish this :

if there are 3 names: A B and C, I want it to be displayed like this : A B C and not like this : ABC


Solution

  • You can use

    <span class="upload-bar__file-name" data-bind="text: '&nbsp;' + name"></span>
    

    to add a so-called "non-breaking space" to the name