NewBie
NewBie

Reputation: 3564

JSON ignoring text after space(whitespace)

I have a JSON which is of this format

   var json = [{
            "html": "Brand 5", //testing this failed
            "col": 1,
            "row": 1,
            "size_y": 2,
            "size_x": 3
        }, {
            "html": "Brand 5", 
            "col": 4,
            "row": 1,
            "size_y": 2,
            "size_x": 2
        },

        {
            "html": "Brand 5",
            "col": 6,
            "row": 1,
            "size_y": 2,
            "size_x": 2
        },


        {
            "html": "Brand 5",
            "col": 1,
            "row": 3,
            "size_y": 2,
            "size_x": 3
        }, {
            "html": "Brand 5",
            "col": 4,
            "row": 3,
            "size_y": 2,
            "size_x": 2
        },

        {
            "html": "Brand 5",
            "col": 6,
            "row": 3,
            "size_y": 2,
            "size_x": 2
        }

        ];

And I try to put it on my gridster with help of this code

for(var index=0;index<json.length;index++) {
        gridster.add_widget('<li class="new" ><button class="delete-button" style="float: right;">-</button><input type="text" size="3" value=' +json[index].html+ '/></li>',json[index].size_x,json[index].size_y,json[index].col,json[index].row);

};

But the problem is that the text after space is ignored what could be reason for this

I only get Brand and not Brand 5 in my textbox

Upvotes: 0

Views: 77

Answers (1)

D. Braun
D. Braun

Reputation: 508

You forgot 2 times: "

It must be:

....value="' +json[index].html+ '"/>....

Upvotes: 2

Related Questions