diff options
-rw-r--r-- | misc/upload.js | 9 | ||||
-rw-r--r-- | modules/upload/upload.module | 4 |
2 files changed, 7 insertions, 6 deletions
diff --git a/misc/upload.js b/misc/upload.js index 1c28bcfa3..4365749cf 100644 --- a/misc/upload.js +++ b/misc/upload.js @@ -13,10 +13,11 @@ function uploadAutoAttach() { for (i = 0; input = inputs[i]; i++) { if (input && hasClass(input, 'upload')) { var uri = input.value; - // Extract the button ID based on a substring of the input name: edit[foo][bar] -> foo-bar - var button = input.name.substr(5, input.name.length - 6).replace('][', '-'); - var wrapper = button + '-wrapper'; - var hide = button + '-hide'; + // Extract the base name from the id (edit-attach-url -> attach). + var base = input.id.substring(5, input.id.length - 4); + var button = base + '-button'; + var wrapper = base + '-wrapper'; + var hide = base + '-hide'; var upload = new jsUpload(uri, button, wrapper, hide); } } diff --git a/modules/upload/upload.module b/modules/upload/upload.module index 481e177dc..d0ed472b2 100644 --- a/modules/upload/upload.module +++ b/modules/upload/upload.module @@ -801,9 +801,9 @@ function _upload_form($node) { '#suffix' => '</div>', ); $form['new']['upload'] = array('#type' => 'file', '#title' => t('Attach new file'), '#size' => 40); - $form['new']['attach'] = array('#type' => 'button', '#value' => t('Attach'), '#name'=> 'attach', '#attributes' => array('id' => 'attach')); + $form['new']['attach'] = array('#type' => 'button', '#value' => t('Attach'), '#name' => 'attach', '#attributes' => array('id' => 'attach-button')); // The class triggers the js upload behaviour. - $form['attach'] = array('#type' => 'hidden', '#value' => url('upload/js', NULL, NULL, TRUE), '#attributes' => array('class' => 'upload')); + $form['attach-url'] = array('#type' => 'hidden', '#value' => url('upload/js', NULL, NULL, TRUE), '#attributes' => array('class' => 'upload')); } // Needed for JS |