jPut icon indicating copy to clipboard operation
jPut copied to clipboard

Remove '_' underscore from json after load

Open ThumperDone opened this issue 8 years ago • 2 comments

Once I pull an external Json file and see it in template, how can I run other JS scripts like removing the underscore found on some Key's? I'm using the below script on a static page and it works fine...

$(window).load(function() { $('#cityDetails').each(function() { var $this = $(this); $this.text($this.text().replace(/_/g, ' ')); console.log("underscore loaded"); }); });

ThumperDone avatar Sep 09 '16 19:09 ThumperDone

Can you put your code in jsfiddle (https://jsfiddle.net/)

shabeer-ali-m avatar Sep 10 '16 05:09 shabeer-ali-m

Sorry late reply.. here what I have working so far. http://codepen.io/Thumper/pen/dpoJxB

mind the scripts, for some reason Codepen keeps loading your script first over jQuery, not sure why, but if that happens your script does not work. Just move yours below jQuery and the Json should populate. From there you can see the Underscore doesn't remove from the list. Florida_Keys is the first you might notice.

I do have this working in a Handlebars example under my profile in Codepen as well.

Thanks, Mike

ThumperDone avatar Oct 09 '16 18:10 ThumperDone