[development] php and js in a programmatic block
Victor Kane
victorkane at gmail.com
Sun Nov 28 19:47:30 UTC 2010
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 at logrus.com> wrote:
> On 11/28/2010 9:17 AM, jeff at 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);
> });
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20101128/9a66c7a6/attachment.html
More information about the development
mailing list