-1

I have the codes below:

    var viewModel = kendo.observable({ SampleData: @Html.Raw(Json.Encode(Model))});
    var genRange = "       ";
    var genStan;

    $.each(viewModel.SampleData, function(idx, obj){ 
        $.each(obj, function(key, value) {
            if(key.toString() === "GenabRange") { genRange = value; }
            if(key.toString() === "GenabStanine") { genStan = value; }
        });

        var obj = {
            GenReasoning: genRange + "        " + genStan
        };

        stud.push(obj);

    });

The whitespaces I've added "GenReasoning: genRange + " " + genStan" doesn't work. What is the problem?

Can anyone help me with this?

Example results:

    GenabRange = Cat
    GenabStanine = Foo

    Output
       GenReasoning = Cat Foo

    Expected Output
       GenReasoning = Cat        Foo

Thanks

10
  • Please define "doesn't work". What are you getting, and what are you expecting to get? Commented Aug 28, 2014 at 1:56
  • @Amadan He means the whitespace isn't being rendered... Commented Aug 28, 2014 at 1:57
  • 2
    Are you putting the contents of obj.GenReasoning into the HTML DOM? Commented Aug 28, 2014 at 1:57
  • @MarkGabriel good point, in which case the answer below won't work. I would suggest unicode Commented Aug 28, 2014 at 1:59
  • Is the first line JavaScript @ ? Commented Aug 28, 2014 at 1:59

1 Answer 1

1

Use this code:

var genRange = "       ";

and this code:

var obj = {
    GenReasoning:genRange+"        "+genStan
};

Notes:

  means 'non-breakable space',
browsers will render this as exactly 1 space
instead of combining them
Sign up to request clarification or add additional context in comments.

4 Comments

This question was answered before, why not just redirect him?
It might be better if you explained to him what   is rather than just spoonfeeding him the correct code. :D
@MarkGabriel, added explanation, not just 'spoonfeeding' anymore, :)
Tried this one but it doesn't work

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.