¿Cómo linebreak un texto svg dentro de javascript?
Así que aquí está lo que tengo:
<path class="..." onmousemove="show_tooltip(event,'very long text
\\\n I would like to linebreak')" onmouseout="hide_tooltip()" d="..."/>
<rect class="tooltip_bg" id="tooltip_bg" ... />
<text class="tooltip" id="tooltip" ...>Tooltip</text>
<script>
<![CDATA[
function show_tooltip(e,text) {
var tt = document.getElementById('tooltip');
var bg = document.getElementById('tooltip_bg');
// set position ...
tt.textContent=text;
bg.setAttribute('width',tt.getBBox().width+10);
bg.setAttribute('height',tt.getBBox().height+6);
// set visibility ...
}
...
Ahora, mi texto muy largo de información sobre herramientas no tiene un salto de línea, aunque si uso alert (); me muestra que el texto realmente tiene dos líneas. (Contiene una "\", sin embargo, ¿cómo elimino esa por cierto?)
No consigo que CDATA funcione en ninguna parte.