[英]Can I get the current HTML from a sidebar in a Google Apps Script code file?
I writing a Google Apps Script (Sheet Add-on), and I'd like to get the HTML of the currently displayed sidebar back to the server-side script. 我编写了一个Google Apps脚本(Sheet附加组件),我想将当前显示的侧边栏的HTML返回到服务器端脚本。 The reason is that I'm making a template-based system where the HTML of the side bar may have come from a range of possible templates, but all of the templates have the same callback function back to the server to make writing them easier.
原因是我正在制作一个基于模板的系统,其中侧栏的HTML可能来自一系列可能的模板,但是所有模板都具有相同的回调函数,可以使它们返回服务器,从而简化了编写过程。 So the common callback function on the server-side needs to be able to determine what HTML it was called from.
因此,服务器端的通用回调函数必须能够确定从哪个HTML调用。
Is there any way to do this? 有什么办法吗?
Do you really need all the HTML? 您真的需要所有HTML吗? Or just enough information to know which template was used?
或者只是足够的信息来知道使用了哪个模板? When you load the templates initially you can store some metadata about what template was used in, for instance, an HTML element.
最初加载模板时,您可以存储一些有关所用模板的元数据,例如HTML元素。 Something like
<...data-template-type="template 7">
类似于
<...data-template-type="template 7">
When you make the call to the server, grab that information from the HTML element and provide it as an argument. 调用服务器时,请从HTML元素中获取该信息并将其作为参数提供。
Hope I understood the question and what you're trying to do. 希望我理解这个问题以及您要做什么。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.