AnsweredAssumed Answered

White space in attributes

Question asked by shawnroberts on May 14, 2019
Latest reply on May 15, 2019 by shawnroberts

I've got a popup on a map that when you click a custom button on the popup it passes some parameters to another function for processing. For the purpose of this question though I've simplified the button to just write to the console.


These parameters are attributes that come from the layer map. The problem I'm experiencing is some of these attributes have white space in them so I can't pass them into the function without getting an error. I know this is more of a JS problem not really a JS API problem but just seeing if anyone has found a way around this issue before. 


var popupViewDetailsButton = "<button class='button popupButton' id='viewDetailsPopupButton' onclick=console.log('{Transaction_Type}')>ViewDetails</button>";


For example the transaction type above could be "For Sale" or "For Lease".

When it tries to write to the console I get an "Invalid or unexpected token"  console.log('For .... where it has stopped after the first space. 


I've tried something like {Transaction_Type}.replace(' ','_') but that doesn't seem to work either. I can't change the values on the server side, and I've also tried to encode the value again neither have worked.


Any guidance or assistance would be greatly appreciated!