我在Tridion 2011 SP1的功能区工具栏中添加了一个按钮.当我点击按钮时,它将打开一个aspx页面.在aspx页面旁边,我需要访问当前光标所在的当前字段名称.请告诉我使用哪个对象?对于我使用的模式名称$display.getView().getItem().getSchemaId().同样有没有办法得到当前的字段名称?
我得到的最接近的是使用此代码(在组件编辑窗口中):
$display.getView().getSourceEditorName()
Run Code Online (Sandbox Code Playgroud)
这将返回当前字段的名称,即使方法名称表明它执行其他操作.
如果您想从弹出窗口中获取相同的值,请按以下方式调用它opener:
opener.$display.getView().getSourceEditorName()
Run Code Online (Sandbox Code Playgroud)
不要在弹出窗口中查找字段名称,而应该在调用命令时将其作为参数传递给弹出窗口.您可以从target传递给_executeCommand方法的参数中获取它.
GUI.Extension.prototype._execute = function GUI$Extension$_execute(target) {
target.editor.setFocus();
var fieldName = target.item.getSourceEditorName();
var popup = $popup.create("/WebUI/Editors/GUI.Extensions/Extension.aspx",
"width=400px,height=150px,resizable=0",
{ fieldName: fieldName });
}
Run Code Online (Sandbox Code Playgroud)
然后使用以下命令在弹出窗口的JavaScript中读取它:
var fieldName = window.dialogArguments.fieldName;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
226 次 |
| 最近记录: |