Replace function

by Alex » Mon Jun 12, 2017 10:15 am

hi,
is it possible to use a replace function inside template configuration?

e.g.
I have
...
{{#if Substitute}}
<div class="field-container" id="substitute">
Official Deputy: {{Substitute}}</a>
</div>
{{/if}}
...
{{Substitute}} comes as domain\name, and I want to remove existing domain name from {{Substitute}}

br,
Alex
Alex
 
Posts: 5
Joined: Mon Jun 12, 2017 10:11 am

by andrelima » Mon Jun 12, 2017 7:09 pm

Hi Alex,
Thanks for getting in touch.

First, I recommend you to use a class of "substitute" instead of an id as it will appear probably more than once in your chart.
Then you can use the class and write a custom JavaScript code to skip the URL and show only the name.

Please send a screenshot of the results you're getting in your chart now so I can help you write the correct script to do it.

Best regards,
Andre Lima,
Plumsail Team.
User avatar
andrelima
 
Posts: 60
Joined: Wed Apr 19, 2017 2:06 pm

by Alex » Tue Jun 13, 2017 6:03 am

Thank you for the hint ;)
I was trying to use Handlebars #replace....

solved it now using jQuery:
Code: Select all
renderer.onTooltipRendered(function(event, tooltip, itemData){
  var substitute = itemData.Substitute;
  $('.substitute').text(substitute.replace('domain\\',''));
});

br,
Alex
Alex
 
Posts: 5
Joined: Mon Jun 12, 2017 10:11 am

by andrelima » Thu Jun 15, 2017 11:13 pm

Hi Alex,
Good to know that you made it work.

Replace HandleBars should work for this too.

Best regards,
Andre Lima
Plumsail Team.
User avatar
andrelima
 
Posts: 60
Joined: Wed Apr 19, 2017 2:06 pm

by Alex » Fri Jun 16, 2017 6:16 am

Hi Andre,

the {{#replace}} function seems not to be a part of loaded Handlebar scripts which are shipped with Orgchart.

br, Alex
Alex
 
Posts: 5
Joined: Mon Jun 12, 2017 10:11 am


Return to Org Chart for SharePoint 2013