Select to view content in your preferred language

Layer list - add extra text

403
1
01-04-2024 01:28 AM
Labels (1)
LeifNorberg1
New Contributor II

I want to add text after each layer list object, which I guess would be done by editing LayerListView.js. The ideal scenario is being able to add a link after each object, where the link contains the layer name. Anyone got any suggestions on how to achieve that?

How it currently works:
<div class="layer-title-div-1704359275081r8878678241822502 div-content jimu-float-leading ">ncov_cases – Deaths</div>

What I am after:

<div class="layer-title-div-1704359275081r8878678241822502 div-content jimu-float-leading ">ncov_cases – Deaths</div><a target="_blank" href="https://customurl/?layer=ncov_cases – Deaths#viewdata" style="text-decoration: none"><span title="Read more">🛈</span></a>

Tags (1)
0 Kudos
1 Reply
LeifNorberg1
New Contributor II

I found that I could do this, but there is a problem:
var layerTitleDivIdClass = 'layer-title-div-' + layerInfo.id;
divLabel = domConstruct.create('div', {
'innerHTML': jimuUtils.sanitizeHTML(layerInfo.title + '<a target="_blank" href="https://customurl/?layer='+ layerInfo.title + '#viewdata" style="text-decoration: none"><span title="Read more">🛈</span></a>'),
'class':layerTitleDivIdClass + ' div-content jimu-float-leading ' + grayedTitleClass
}, layerTitleTdNode);

I can't seem to keep the target="_blank", since the result is:
<div class="layer-title-div-1704363952933r5863144829289666 div-content jimu-float-leading ">ncov_cases – Cases<a href="https://customurl/?layer=ncov_cases – Cases#viewdata"><span title="Read more">🛈</span></a></div>

 

I could remove the sanitizing and it would just work, but of course it would be better to keep it. If anyone have any suggestions I would be grateful.

0 Kudos