Page 1 of 2

content break line

Posted: Sun Apr 05, 2015 1:46 pm
by Spark Chao

he
can someone kindly tell me how to let content break line in label component?
the content will get from db in string form.
Image


content break line

Posted: Sun Apr 05, 2015 3:43 pm
by M&M

You mean you want to add a break in between lines?


content break line

Posted: Sun Apr 05, 2015 6:34 pm
by Spark Chao

Yes,so thanks!


content break line

Posted: Mon Apr 06, 2015 2:29 am
by Spark Chao

I hope it can be like that below.thanks you so much!
Image


content break line

Posted: Mon Apr 06, 2015 3:02 am
by Yurii Orishchuk

HI Spark,

Yes you can use HTML code to make markup for label component.
But you can set this HTML only with JS code.

Here is an example:

precode

//this is your HTML code
var html = "1st line<br/>2nd line<br/>3rd line&quot

&#47;&#47;Set HTML to labelName component&#46;
Apperyio("labelName")&#46;html("html");

/code/pre

Regards.


content break line

Posted: Mon Apr 06, 2015 3:10 am
by Spark Chao

Yurii
thanks for your reply.
so I just post the code above to the db in string form?
and get that form db to label component?

or I need to use "load event" to set the label component to html?
thanks


content break line

Posted: Mon Apr 06, 2015 3:32 am
by Spark Chao

Yurii
I try to way to test .please guide me how to fix that.
way one:
use html component in page,and key in content in db like below.
Image
this way is work!
Image

way two:
use label component in page,and key in content is db like below.
var html = "1st line
2nd line
3rd line";
and set the load event with run js.
Apperyio("labelName").html("html");
this way is no working .
did I did any thing wrong?


content break line

Posted: Mon Apr 06, 2015 3:41 am
by M&M

You can replace your line breaks with the html code<br>/code this way

code
str = str&#46;replace(/(?:\r\n|\r|\n)/g, '<br />');
/code

So if your existing text has line breaks, then JS will convert them into HTML line breaks


content break line

Posted: Mon Apr 06, 2015 5:15 am
by M&M

You got to remove the double quotes
It should be Apperyio("labelName").html(html);


content break line

Posted: Mon Apr 06, 2015 5:29 am
by Spark Chao

so sorry
when I use the load event to set the js .
the page will no open!