[Archivesspace_Users_Group] Plugin problems: want the Notes section to default to open
Blake Carver
blake.carver at lyrasis.org
Fri May 31 12:56:03 EDT 2019
Hi Nick,
Did you ever get this one figured out?
________________________________
From: archivesspace_users_group-bounces at lyralists.lyrasis.org <archivesspace_users_group-bounces at lyralists.lyrasis.org> on behalf of Nick Butler <npwb2 at cam.ac.uk>
Sent: Tuesday, May 21, 2019 10:10 AM
To: archivesspace_users_group at lyralists.lyrasis.org
Subject: [Archivesspace_Users_Group] Plugin problems: want the Notes section to default to open
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/20190531/a6cf39ef/attachment.html>
More information about the Archivesspace_Users_Group
mailing list