? jsform.kpf
? jsform.patch
? poll_more_label.patch
? sites/jsform
Index: includes/form.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/form.inc,v
retrieving revision 1.235
diff -u -p -r1.235 form.inc
--- includes/form.inc	16 Oct 2007 14:06:23 -0000	1.235
+++ includes/form.inc	18 Oct 2007 06:36:07 -0000
@@ -1825,11 +1825,18 @@ function theme_textfield($element) {
  *
  * @param $element
  *   An associative array containing the properties of the element.
- *   Properties used: action, method, attributes, children
+ *   Properties used: scripts, action, method, attributes, children.
+ *
+ *   If $form['#scripts'] is populated, each element in its array
+ *   will be passed on to drupal_add_js() for inclusion in the final
+ *   rendered page.
  * @return
  *   A themed HTML string representing the form.
  */
 function theme_form($element) {
+  foreach($element['#scripts'] as $key => $script) {
+    call_user_func_array('drupal_add_js', $script);
+  }
   // Anonymous div to satisfy XHTML compliance.
   $action = $element['#action'] ? 'action="'. check_url($element['#action']) .'" ' : '';
   return '<form '. $action .' method="'. $element['#method'] .'" id="'. $element['#id'] .'"'. drupal_attributes($element['#attributes']) .">\n<div>". $element['#children'] ."\n</div></form>\n";
Index: modules/poll/poll.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/poll/poll.module,v
retrieving revision 1.245
diff -u -p -r1.245 poll.module
--- modules/poll/poll.module	17 Oct 2007 19:36:12 -0000	1.245
+++ modules/poll/poll.module	18 Oct 2007 06:36:08 -0000
@@ -238,9 +238,13 @@ function poll_form(&$node, $form_state) 
     ),
   );
 
-  // If we're using the javascript version (99% use-case), change the button
-  // title to 'Add another choice' to reflect the javascript behavior.
-  drupal_add_js("if (Drupal.jsEnabled) { $(document).ready(function() { $('#edit-poll-more').val('". t('Add another choice') ."'); }); }", 'inline');
+  // Change the button title to reflect the behavior when using JavaScript.
+  // We put this in $form['#scripts'] so it will be passed on to drupal_add_js()
+  // whenever the form is rendered, not just the first time it's built.
+  $form['#scripts']['poll_more'] = array(
+    'data' => 'if (Drupal.jsEnabled) { $("#edit-poll-more").val("'. t('Add another choice') .'"); }',
+    'scope' => 'inline',
+  );
 
   // Poll attributes
   $_duration = array(0 => t('Unlimited')) + drupal_map_assoc(array(86400, 172800, 345600, 604800, 1209600, 2419200, 4838400, 9676800, 31536000), "format_interval");
Index: modules/system/system.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.module,v
retrieving revision 1.543
diff -u -p -r1.543 system.module
--- modules/system/system.module	17 Oct 2007 21:59:31 -0000	1.543
+++ modules/system/system.module	18 Oct 2007 06:36:08 -0000
@@ -126,7 +126,7 @@ function system_perm() {
  */
 function system_elements() {
   // Top level form
-  $type['form'] = array('#method' => 'post', '#action' => request_uri());
+  $type['form'] = array('#method' => 'post', '#action' => request_uri(), '#scripts' => array());
 
   // Inputs
   $type['submit'] = array('#input' => TRUE, '#name' => 'op', '#button_type' => 'submit', '#executes_submit_callback' => TRUE, '#process' => array('form_expand_ahah'));
