0

I have a JSON that contains values of "some thing" and "some/thing/other" as possible values that I want to write to:

$('li#'+fixRegion).append('<ul class="sub"/>');

I tried doing:

var fixRegion = region.replace(/\s/g,'');
fixRegion = fixRegion.replace(/\//g,'');

but it crashes firefox and I won't even bother to tell you want it does with firebug open. What horribly obvious thing am I doing wrong?

jbolanos
  • 615
  • 3
  • 9
  • 20
  • That doesn't crash firefox for me when I run it in t he console ... what's the actual value of the JSON? – Explosion Pills Jun 21 '13 at 00:20
  • the JSON is very long - its pretty much a data dump of all the zones, area, regions, markets, and switches for the United States. About 300 values will match region. – jbolanos Jun 21 '13 at 00:21
  • I tried combining them but that doesn't seem to work either .replace(/\/\s/g,'') – jbolanos Jun 21 '13 at 00:29
  • What about `.replace(/\/|\s/)`? – Explosion Pills Jun 21 '13 at 00:30
  • Have you tried using the solution suggested [in this question](http://stackoverflow.com/a/3113742/1348195) – Benjamin Gruenbaum Jun 21 '13 at 00:33
  • yeah - also crash - too much data I think. I'm just going to put it in a data attribute field and point to that so it can be any value – jbolanos Jun 21 '13 at 00:35
  • yup - too much data - even that fix and it exploded on me. – jbolanos Jun 21 '13 at 00:49
  • @jbolanos Honestly I wouldn't be querying the dom based on `"#"+varname`. That usually indicates a bigger design problem. Still, it shouldn't crash firefox - you should file a bug report. – Benjamin Gruenbaum Jun 21 '13 at 00:59
  • @BenjaminGruenbaum You are right - I switched to using data elements and that solved that problem. I also figured out the reason its crashing - I'm recursively looping creating an impossible condition the browser doesn't have the resources to meet. – jbolanos Jun 21 '13 at 15:34
  • Data elements are just as bad. If you created the elements what's wrong with simply keeping them in an array and having actual JS objects back them up? Consider separating concerns, why are you storing application state in your presentation layer and then querying it? You can use JavaScript objects for that. – Benjamin Gruenbaum Jun 21 '13 at 15:45

0 Answers0