I realize now that I don't know whether I'm coming or going... Excellent the distinction between server side and client side, would be good to do a little drawing showing the order in which things get executed and the params passed (interaction diagram or sequence diagram). Victor On Sun, Nov 28, 2010 at 4:00 PM, Earl Miles <merlin@logrus.com> wrote:
On 11/28/2010 9:17 AM, jeff@ayendesigns.com wrote:
<script type="text/javascript" src="http://www.mydomain.com/test.js"></script> <script type="text/javascript"> var settings = Drupal.settings.mymodule; myfunction(settings.name,settings.total); </script>
The problem is likely order of code running. Settings won't have been read in yet. You need to use jquery's s ready() function. IMO you should put this directly into your test.js file and not embed inline javascript at all. If your javascript is going to do a .write() or something, you are best off using a <div> that will be replaced. So at the bottom of your test.js, something like this:
// $(function() { }) is a synonym for $.ready(). // This ensures that the code is not executed until the page is rendered. $(function() { var settings = Drupal.settings.mymodule; myfunction(settings.name,settings.total); });