[Archivesspace_Users_Group] Plugin problems: want the Notes section to default to open

Nick Butler npwb2 at cam.ac.uk
Tue May 21 10:10:51 EDT 2019


Hi all,

We're trying to write a plugin to default the Notes section of the new and edit resources pages to being open (i.e. as if the "Add Note" button had been clicked automatically when the page loaded).

I've got a layout_head.html.erb file which loads the appropriate js file in the correct page, my difficulty just comes from getting the button to click without creating errors. Here are the contents of my js file:

$(function () {
  var click_the_button = function () {
    var button = document.querySelector('.btn.btn-sm.btn-default.pull-right.add-note');
    button.click();
  };
  click_the_button();
});

When the page loads I get the error messages seen in my attached screenshot. I've also tried requiring notes.crud.js and simply running the createTopLevelNote function, but this gives precisely the same error messages. Note that the URL for creating a new resource is https://arcspace-dev.lib.cam.ac.uk/staff/resources/new, but when the error messages appear this changes to https://arcspace-dev.lib.cam.ac.uk/staff/resources.

As a test I've changed the click_the_button function to perform another task instead:

var click_the_button = function () {
    var button = document.querySelector('.btn.btn-sm.btn-default.pull-right.add-note');
   button.style.backgroundColor = 'green';
  };

This works exactly as expected, changing the button colour to green. No error messages appear and the URL stays as expected.

I haven't found any other plugins that do something like this (and I know very little Javascript!) so I'm at a loss here. Any advice or links to relevant documentation would be greatly appreciated.

Many thanks,
Nick

--

Nick Butler
Software Developer
Digital Services
Cambridge University Library
West Road
Cambridge CB3 9DR, UK

npwb2 at cam.ac.uk<mailto:npwb2 at cam.ac.uk>

Internal tel: 33067
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lyralists.lyrasis.org/pipermail/archivesspace_users_group/attachments/20190521/1e7351ce/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screenshot from 2019-05-21 15-04-26.png
Type: image/png
Size: 229245 bytes
Desc: Screenshot from 2019-05-21 15-04-26.png
URL: <http://lyralists.lyrasis.org/pipermail/archivesspace_users_group/attachments/20190521/1e7351ce/attachment.png>


More information about the Archivesspace_Users_Group mailing list