im使用灵活性在plone中创建内容类型。。到目前为止还不错。。但我想创建一个Schema。Bool,当它检查时,它会隐藏一些字段。这是我的样品
sameaddress = schema.Bool(
title=_(u"Sames as bill to address"),
required=False,
)
toCustShipStreet = schema.TextLine(
title=_(u"Ship to - Street:"),
)
toCustShipCity = schema.TextLine(
title=_(u"Ship to - City:"),
)
toCustShipState = schema.TextLine(
title=_(u"Ship to - State:"),
)
toCustShipCountry = schema.TextLine(
title=_(u"Ship to - Country:"),
)
我该怎么做??请帮助
我正在使用我的小JavaScript库对Plone网站进行此操作
https://github.com/miohtama/jquery-interdependencies
-
嵌入deps.js作为JavaScript资源
-
创建一个控制器文件,该文件定义了规则布尔字段隐藏的小部件和其他内容(这实际上不是Plone特定的,你可以放入任何CSS ID)
-
确保每次正确的页面加载时逻辑都会启动
示例widget-rules.js
(出于保密原因,我无法提供完整的示例,但这应该会给您一些提示):
/*global console*/
(function($) {
"use strict";
// jQuery selector for all possible different stenosis fields (CR, MR, treatment)
var stenosisFields = "#formfield-thrombectomyVariables-widgets-thrombectomyVariables_treatmentSpecifylocalizationOfStenosis";
function log(msg) {
if(console && console.log) {
console.log(msg);
}
}
/**
* Generate datagridfield block jQuery class selection based on field name.
*
* Note that the same field will appear multiple times on the page.
*/
function getDGFId(fname) {
return ".datagridwidget-widget-" + fname;
}
function buildRules() {
// Start creating a new ruleset
var ruleset = $.deps.createRuleset();
var masterSwitch = ruleset.createRule("#typeOfStenosisOcclusion") + " select", "==", "other");
// Make this controls to be slave for the master rule
masterSwitch.include("#typeOfStenosisOcclusionWhich");
return ruleset;
}
function init() {
// Master field containing all MTD rows
var fields = $(stenosisFields);
if(fields.size() > 0) {
var ruleset = buildRules();
initRules($this, ruleset);
followRules($this, ruleset);
}
}
$(document).bind("ready", init);
})(jQuery);