Trouble with changing classes in stand-alone apps script

30 views
Skip to first unread message

Greg Borchard

unread,
May 18, 2020, 3:09:29 AM5/18/20
to Google Apps Script Community
What I'm doing: I'm developing an Add-on for Google Sheets, so a stand alone script. I have 3 separate files - Javascript, CSS & HTML for a sidebar. The sidebar contains a list of options inside select tags.

Required outcome: Depending on what is selected in the options, only the associated div should be displayed in the sidebar (the others have display: none). When the select ID is changed, the listSelector function operates to remove the toggle class (so as to hide currently displayed div) and assign toggle to the selected div from the options list.

Problem I'm experiencing: I'm having difficulty in getting classes added and removed from HTML elements using JavaScript.

The console shows an error,

"Uncaught (in promise) TypeError: Cannot read property 'querySelectorAll' of null"

although I'm not sure whether that is related to my problem. I have replicated the code in JSFiddle and this works as expected: https://jsfiddle.net/gborchard/1u7p3o2g/

I just don't see why the problem is occurring in Apps Script. Any suggestions please? Even on where to start looking?

Andrew Roberts

unread,
May 18, 2020, 5:02:27 AM5/18/20
to google-apps-sc...@googlegroups.com
Hi Greg,

Your fiddle looks OK. V8 is causing strange client-side errors, so the first thing I would try is to see if it works with Rhino.

I'm doing a lot of UI work at the moment, so if you can share all your code I'd be happy/interest to take a look.

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/8d77acbb-9cf1-4f0e-bf77-ac24583df0fc%40googlegroups.com.

Greg Borchard

unread,
May 18, 2020, 7:35:42 PM5/18/20
to Google Apps Script Community
Hi Andrew,

Thank you for your response.  I have resolved the issue - had a typo in my code and now working as expected.


Greg


On Monday, 18 May 2020 19:02:27 UTC+10, andrew wrote:
Hi Greg,

Your fiddle looks OK. V8 is causing strange client-side errors, so the first thing I would try is to see if it works with Rhino.

I'm doing a lot of UI work at the moment, so if you can share all your code I'd be happy/interest to take a look.

On Mon, 18 May 2020 at 08:09, Greg Borchard <gregbo...@gmail.com> wrote:
What I'm doing: I'm developing an Add-on for Google Sheets, so a stand alone script. I have 3 separate files - Javascript, CSS & HTML for a sidebar. The sidebar contains a list of options inside select tags.

Required outcome: Depending on what is selected in the options, only the associated div should be displayed in the sidebar (the others have display: none). When the select ID is changed, the listSelector function operates to remove the toggle class (so as to hide currently displayed div) and assign toggle to the selected div from the options list.

Problem I'm experiencing: I'm having difficulty in getting classes added and removed from HTML elements using JavaScript.

The console shows an error,

"Uncaught (in promise) TypeError: Cannot read property 'querySelectorAll' of null"

although I'm not sure whether that is related to my problem. I have replicated the code in JSFiddle and this works as expected: https://jsfiddle.net/gborchard/1u7p3o2g/

I just don't see why the problem is occurring in Apps Script. Any suggestions please? Even on where to start looking?

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-community+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages