This is a migrated thread and some comments may be shown as answers.

Json don't shows line break but <br/>

4 Answers 1344 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Marco
Top achievements
Rank 1
Marco asked on 21 Sep 2012, 03:41 PM
Hi :) , 

i'm trying to display my string with json but i'm seeing the tag <br/> instead of the line break:

what i expected:
" this is a 
line break"

what i see:
"this is a<br/>line break"

on my document I've write 
<div>${content}</div>

Someone can help me, please? :) :)

4 Answers, 1 is accepted

Sort by
0
Nohinn
Top achievements
Rank 1
answered on 21 Sep 2012, 04:10 PM
Where are you trying to bind this json?
By any chance does your content reach the view encoded so it displays "<br/>" instead of the break-line?
We lack some info.

But as a first and general solution try this:
<div>${content.replace(/<\s*\/?\s*br\s*.*?>/g, "\n")}</div>

Depending on which control you're trying to bind this info it may have an "encoded" property you can set to false and it will render as it should.
0
Marco
Top achievements
Rank 1
answered on 24 Sep 2012, 07:52 AM
Hi,

Here is the json:
function mobileSingleView(id) {
 
    var dataDb = new kendo.data.DataSource({
        transport: {
            read: {
                contentType: "application/json; charset=utf-8",
                url: "url?id=" + id,
                dataType: "json",
                type: "POST",
                error: function(xhr, status) {
                    console.log(status);
                }
            }
        },
        schema: { // describe the result format
 
            data: function (data) {
                return eval(data.project);
            }
        }
    });
 
    $("#temp").kendoMobileListView({
        dataSource: dataDb,
        pullToRefresh: false,
        appendOnRefresh: false,
        template: $("#template").html()
    });
 
    document.location.href = '#scheda';
}

Yeah, the content displays  "<br/>" instead of the break-line, and I tried your general solution but it doesn't work... :(
0
Marco
Top achievements
Rank 1
answered on 25 Sep 2012, 02:02 PM
No one helps me?
0
Marco
Top achievements
Rank 1
answered on 01 Oct 2012, 07:16 AM
Tags
General Discussions
Asked by
Marco
Top achievements
Rank 1
Answers by
Nohinn
Top achievements
Rank 1
Marco
Top achievements
Rank 1
Share this question
or