-1

I want to use a javascript variable to calculate the columnWidth variable of the jQuery Masonry plugin. When I view source on my page, I see the variable name in the javascript rather than the variables value.

http://jsfiddle.net/robflate/fS2yL/

Thanks

robflate
  • 177
  • 1
  • 1
  • 9

2 Answers2

3

Javascript is intepreted... it's normal that you see "return containerWidth / columns;" in your source code.

When the javascript will be interpreted, the value of "columns" will be used.

If it does not work, it's surelly because you set "columns" as a string ( "5" ) and not as an integer. The division can't be perfomed.

dievardump
  • 2,484
  • 17
  • 21
  • As I've just said in reply to another question relating to something similar, I'm sure everyone who knows that javascript doesn't update the source is thinking I must be stupid but I honestly never knew that. Thanks for the info and help. – robflate Jan 28 '12 at 17:47
0

That is expected - source will show what you loaded, it won't change the values. See this jsfiddle:

This will work as expected.

icyrock.com
  • 27,952
  • 4
  • 66
  • 85