<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Jeff<br>
<br>
Both this approach (settings) and inline can work.<br>
I suggested this because you have a script that needs dynamic
values.<br>
Making the script a function you can call with the two value and
the inline approach would be another approach.<br>
<br>
Nevets<br>
<br>
<br>
On 11/28/2010 10:04 AM, <a class="moz-txt-link-abbreviated" href="mailto:jeff@ayendesigns.com">jeff@ayendesigns.com</a> wrote:
<blockquote cite="mid:4CF27D94.9080704@ayendesigns.com" type="cite">
<div class="moz-text-html" lang="x-western"> Ah, gotcha. Not sure
this is more intuitive than the other way, but if
it's common practice then so be it :)<br>
Thanks!<br>
<br>
On 11/28/2010 11:02 AM, Steve Ringwood wrote:
<blockquote cite="mid:4CF27D12.9030501@mailbag.com" type="cite">
Jeff<br>
<br>
You still want to drupal_add_js(), but instead of one
call you
want two.<br>
<br>
The first is to add your mymodule.js<br>
<br>
The second is to do something like<br>
<br>
$settings = array(<br>
'MyModule' => array(<br>
'value1' => 'some value',<br>
'value2' => 'some other value'<br>
)<br>
);<br>
<br>
drupal_add_js( $settings, 'setting' );<br>
<br>
You also need to modify mymodule.js to use the values
something like<br>
<br>
var settings = Drupal.settings.MyModule;<br>
// Now you can use<br>
// settings.value1 and settings.value2<br>
<br>
(of course you need to change MyModule to your actual
module name
and I would suggest more meaningful names than value1 and
value2)<br>
<br>
Nevets<br>
<br>
<br>
On 11/28/2010 9:43 AM, <a moz-do-not-send="true"
class="moz-txt-link-abbreviated"
href="mailto:jeff@ayendesigns.com">jeff@ayendesigns.com</a>
wrote:
<blockquote cite="mid:4CF27887.6060002@ayendesigns.com"
type="cite">
<div class="moz-text-flowed" style="font-family: -moz-fixed;
font-size: 13px;" lang="x-western">Nothing
confuses me faster than mixing php and js (and especially
escaping the
quotes). In this case, my confusion is the concept and not
the
gobblygook. <br>
<br>
<br>
I have a module invoking hook_block, and a function that
creates and
returns the block content. In this function I invoke
drupal_add_js to
gather the contents of ./mymodule.js <br>
<br>
<br>
So far so good. However, the js needs to be
dynamic...there are two
function values that need to be embedded in it. I'm
thinking that with
this being the case, drupal_add_js might not be the way to
go (back to
escaping quotes), but wanted to poll first for best
practice, since
I'll be contributing this module. <br>
<br>
<br>
Thanks, <br>
<br>
Jeff <br>
<br>
<br>
</div>
</blockquote>
<br>
</blockquote>
</div>
</blockquote>
<br>
</body>
</html>