By Daniel Du
If you are migrating your application from Ajax Viewer(aka. Basic web layout) to Fusion Viewer(aka. Flexible web layout), you may notice that the hyperlink in selection panel does not work, it displays as raw HTML tags.
(In Fusion Viewer, not as expected )
(in Ajax Viewer, works well)
Here is the solution, you need to edit SelectionPanel.js in C:\Program Files\Autodesk\Autodesk Infrastructure Web Server Extension 2013\www\fusion\widgets. Search “renderFeature”(Around 384) and change code as below:
htmlDecode:function(str){ var s = ""; if(str.length == 0) return ""; s = str.replace(/>/g, ">"); s = s.replace(/</g, "<"); s = s.replace(/ /g, " "); s = s.replace(/'/g, "\'"); s = s.replace(/"/g, "\""); s = s.replace(/<br>/g, "\n"); return s; }, renderFeature: function() { var layerIdx = this.layerList.selectedIndex; var featureIdx = this.featureList.selectedIndex; var layerObj = this.oSelection.getLayer(layerIdx); var nProperties = layerObj.getNumProperties(); var aNames = layerObj.getPropertyNames(); var table = document.createElement('table'); var thead = document.createElement('thead'); var tr = document.createElement('tr'); var th = document.createElement('th'); th.innerHTML = OpenLayers.i18n('attribute'); tr.appendChild(th); var th = document.createElement('th'); th.innerHTML = OpenLayers.i18n('value'); tr.appendChild(th); thead.appendChild(tr); table.appendChild(thead); var tbody = document.createElement('tbody'); table.appendChild(tbody); for (var i=0; i<nProperties; i++) { var tr = document.createElement('tr'); if (i%2) { tr.className = 'oddRow'; } var th = document.createElement('th'); th.innerHTML = aNames[i]; var td = document.createElement('td'); td.innerHTML = this.htmlDecode(layerObj.getElementValue(featureIdx, i)); tr.appendChild(th); tr.appendChild(td); tbody.appendChild(tr); } this.featureDiv.innerHTML = ''; this.featureDiv.appendChild(table); }
The idea is to decode the string value so that it can be rendered correctly. Please pay attention to the comma at the end of the the htmlDecode() function. Of cause you may add this utility function somewhere else to make the whole fusion project more organized, I just add it into SelectionPanel.js for simplicity.
Finally, you need to change the Javascriipt reference to the fusion.js in your template index.html, for example, C:\Program Files\Autodesk\Autodesk Infrastructure Web Server Extension 2013\www\fusion\templates\mapguide\slate\index.html if you are using Slate template:
<script type="text/javascript" src="../../../lib/fusion.js"></script>
Please refer to this post for more information about debugging as well.