0

I'm using the following line to add JavaScript code to my module form:

$form['#after_build'][] = 'myModule_after_build'

In myModule_after_build(), I add the Javascript code with calling drupal_add_js('myJavascript','inline').

Unfortunately, it seems that the JavaScript code is added only during the first page call. I would like to pass some arguments to JavaScript, and manipulate the content of the JavaScript, according to the options in the form.

Is there any configuration that I can set to add 'myJavascript' with different arguments to every button click?

1 Answer 1

1

#after_build is called every time the form it built. I've used this myself many times to add JS to forms. Most likely you have a flaw in the script or after build function itself, or you are using cached data when creating the script to display.

If you posted your code, we could provide a better answer.

2
  • Thanks in advance. I'm using drupal_add_js to add a highcharts javascript. I'm calling this script as it is. I hope there is no flaws in it. When i've manually clear the caches using the admin menu (flush cache tables), the javascript was added. Commented Aug 16, 2011 at 22:58
  • @danielmsd I need to see your actual code, not a description of it Commented Aug 17, 2011 at 6:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.