Ah. Gotcha. Not that it really matters but the $(document).ready part is actually JQuery, a JS framework. The actual JS syntax is much more bulky for discovering the ready state of the DOM.
On Wed, Nov 17, 2010 at 3:45 PM, morgan l <greyk...@gmail.com> wrote: > > As you can probably tell, I don't do much js work. I get the global > declaration part, but I've never used nor understood the > $(document).ready(function() > part. > > I suppose I was thinking the ready function wasn't firing, so the > previously > undeclared variable would be now be null. > > > On Wed, Nov 17, 2010 at 2:33 PM, Michael Grant <mgr...@modus.bz> wrote: > > > > > No, because you are defining it outside of the function, making it > global. > > Then setting it to cfActiveWebrootDirectory when the DOM reports it's in > a > > ready state. > > > > On Wed, Nov 17, 2010 at 3:30 PM, morgan l <greyk...@gmail.com> wrote: > > > > > > > > Won't that just make it null instead of undefined when the "url:" line > of > > > the included .js file runs? Not that I have a better answer. > > > > > > On Wed, Nov 17, 2010 at 2:20 PM, Michael Grant <mgr...@modus.bz> > wrote: > > > > > > > > > > > Define your var outside of the function. > > > > > > > > <script type="text/javascript"> > > > > > > > > var jsActiveWebrootDirectory; > > > > > > > > $(document).ready(function() { > > > > > > > > jsActiveWebrootDirectory = '#cfActiveWebrootDirectory#'; > > > > > > > > }); > > > > > > > > > > > > </script> > > > > > > > > > > > > On Wed, Nov 17, 2010 at 2:20 PM, Rick Faircloth < > > > r...@whitestonemedia.com > > > > >wrote: > > > > > > > > > > > > > > I'm trying to set a js var using cf in the head of a file, then use > > > > > that js var in an externally called js file... > > > > > > > > > > > > > > > If I'm using this in the head of a .cfm page to set a js var with > cf: > > > > > > > > > > <cfset cfActiveWebrootDirectory = > > > > > application.activeWebrootDirectory> > > > > > > > > > > <cfoutput> > > > > > > > > > > <script type="text/javascript"> > > > > > > > > > > $(document).ready(function() { > > > > > var jsActiveWebrootDirectory = > > > > > '#cfActiveWebrootDirectory#'; > > > > > }); > > > > > > > > > > </script> > > > > > > > > > > </cfoutput> > > > > > > > > > > and the following in the js file, "01-processEmailProperty.js": > > > > > > > > > > url: '' + jsActiveWebrootDirectory + > > > > > > > > > > > > > > > > > > > > '/modules/emailProperty/00-propertyEmailProcessing.cfc?method=mEmailProperty > > > > > &returnFormat=json' > > > > > > > > > > The line "url" line immediately above is part of the js file that > is > > > > > referenced in the .cfm > > > > > mentioned at the top of this message as an external js file like > > this: > > > > > > > > > > <script type="text/javascript" > > > > > src="modules/emailProperty/01-processEmailProperty.js"></script> > > > > > > > > > > Why would the var, "jsActiveWebrootDirectory", always be > "undefined" > > in > > > > the > > > > > file containing the "url" line above when the > > > 01-processEmailProperty.js > > > > > function is called? > > > > > > > > > > > > > > > Does the question make sense? > > > > > I can reword it if it's not clear... > > > > > > > > > > Rick > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:339338 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm