frappe - Frappe: cur_frm.add_custom_button() does not add a Custom-Button
问题描述
I'm creating custom-buttons in a Client Script. This code works:
// Buttons do appear, everything is fine
frappe.ui.form.on('Article', {
refresh(frm) {
frm.add_custom_button("Hello", () => {
msgprint("Hello");
}, "Greet");
frm.add_custom_button("Ciao", () => {
msgprint("Ciao");
}, "Greet");
}
Then I thought about creating the buttons outside the events with cur_frm, which doesn't work. Why is this so?
// Buttons don't appear
cur_frm.add_custom_button("Hello", () => {
msgprint("Hello");
}, "Greet");
cur_frm.add_custom_button("Ciao", () => {
msgprint("Ciao");
}, "Greet");
解决方案
cur_frm
is deprecated API. Why can't you use frm
from one of the JS event methods?
推荐阅读
- javascript - 这两种时间格式有什么区别以及如何转换
- javascript - JQuery - 从父 div 中获取未知数量的孩子的 id 值
- c# - 错误:已发布代码上的“找不到路径的一部分”
- json - 如何在python中附加一个json文件
- liferay - 未找到 Liferay 7 会话
- google-cloud-source-repos - 尽管源存储库管理员角色,开发人员无法创建存储库
- c# - 尝试在 Unity 中使用 raycast (2D) 拾取与玩家位置相关的对象(如果它靠近它)
- python - 从 Python 调用 LabVIEW/Windows API DLL
- javascript - 如何使 DIV 向上扩展而不是向下扩展?
- soap - 如何使用 FRENDS 发出 SOAP 请求?