jPut
jPut copied to clipboard
Remove '_' underscore from json after load
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"); }); });
Can you put your code in jsfiddle (https://jsfiddle.net/)
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