[jQuery] forcing string literals

2007-08-03 Thread Todd Harris

Hi all -

I have a JSON response with a parameter like

count: 0;

But if I try appending this value in a chained command, jQuery
interprets this as false and not a string literal.

eg
$(counts_col).append(json.count);

Is there a trick to making 0 a string literal and not a boolean
false?  eval()?

Thanks!



[jQuery] Re: forcing string literals

2007-08-03 Thread Todd Harris

Aha!  Much thanks, Klaus!

On Aug 3, 1:38 pm, Klaus Hartl [EMAIL PROTECTED] wrote:
 Todd Harris wrote:
  Hi all -

  I have a JSON response with a parameter like

  count: 0;

  But if I try appending this value in a chained command, jQuery
  interprets this as false and not a string literal.

  eg
  $(counts_col).append(json.count);

  Is there a trick to making 0 a string literal and not a boolean
  false?  eval()?

  Thanks!

 Stay away from eval ;-)

 Here's the little trick, make it a string:

 $(counts_col).append(json.count + '');

 --Klaus