I need to put different information in separate lines, I have a working Javascript library, but I can't force the text output to display a newline. Here is the relevant part of the Javascript:
var information = layer.objectAdd({
type:"tooltip",
clickable: true,
Title: "My title",
Description: "My description1 \nMy description2"});
Here is the desired output:
My description1
My description2
And here is what I get:
My description1 My description2
Why is this, I mean is there another way to jump to a newline?
Sorry if I missled someone, I have a Javascript library for generating tooltips. I cannot change it because it's not my decision to make. I need to make it work, and I can't use any HTML tags because I will get it printed out because it's not being rendered in HTML. Like, I just tried
Description: "My description1 <br /> My description2"});
And it just printed My description1 <br /> My description2. Same old, same old.
UPDATE: I have no control over it how is it displayed, I'm just filling in the available properties such as click able, Title, Description etc. And I've tried to add HTML inside Description, but it just outputs everything as a string no matter what code you write.
It depends on what you're doing with the text, but my guess is you're rendering it as Html. In that case, you should be using a <br /> tag instead of a \n.
EDIT: It sounds like this doesn't solve your problem, because html tags are encoded and displayed, rather than interepreted as html tags. In that case, you'll either have to modify your tooltip display library, or go with a different library.
What kind of tootips? If it's a JavaScript library that floats divs over the page you would need to change the library to detect the \n and insert a line break.
If it's simple title attributes, I'm afraid you can't (reliably) have a newline in them at all. Some browsers will render title="a b" (or the JavaScript equivalent element.title= 'a\nb';) on two lines; others won't.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With