JsRender concat values without space

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
sangnandar
User
Posts: 980

JsRender concat values without space

Post by sangnandar »

Is there a way to concat custom template (JsRender) values without space?
For example:
fieldA, value = Something
fieldB, value = AnotherSomething

{{{value fieldA}}}{{{value fieldB}}} gives "Something AnotherSomething".

I need "SomethingAnotherSomething".

Thanks.


mobhar
User
Posts: 11660

Post by mobhar »

The closest approach for this is by concating those two fields by using a Custom Field, and then simply display that Custom Field value in your Custom Template.


sangnandar
User
Posts: 980

Post by sangnandar »

Apparently the space is caused by html line-break between <span>'s of fieldA and fieldB.
So I ended up with this solution:
<span name="destroy">{{{value fieldA}}}{{{value fieldB}}}</span> ; // enclose the <span>'s with a <span>

Then destroy the line-break between <span>'s using startup script:
$("span[name=destroy]").each(function(){ //using .each() because it's a List Page
var str = $(this).html().replace(/[\n\r]/g,'');
$(this).html(str);
});

I thinks it's tidier this way since custom field might need additional Row_Rendered() code if the values are lookup.

Thanks btw.


mobhar
User
Posts: 11660

Post by mobhar »

sangnandar wrote:
since custom field might need additional Row_Rendered() code if the values are lookup.

Try to play with "CurrentValue" and "ViewValue" that belongs to the Field object.


Post Reply