【发布时间】:2017-10-31 07:19:00
【问题描述】:
我需要在页面加载时在服务门户下的目录项中的文本字段中添加占位符,我尝试在目录客户端脚本中使用 jquery 和 angular/document 但没有成功,发现它不支持任何其他替代解决方案?
目录客户端脚本:
function onLoad() {
var elm = angular.element(element.getElementsByClassName("form-control"));
//when I use angular I get this error:
js_includes_sp.jsx?v=08-28-2017_0947&lp=Mon_Aug_28_11_44_06_PDT_2017&c=2_42:63808 (g_env) [SCRIPT:EXEC] 运行客户端脚本“Placeholder”时出错 Script": TypeError: Cannot read property 'element' of null.
jQuery("#sp_formfield_IO:5cdafd764f02030007b03fb28110c70b").attr("placeholder","hello world");
// if I use jquery or $jq I get below error
(g_env) [SCRIPT:EXEC] 运行客户端脚本“Placeholder”时出错 Script": TypeError: jQuery is not a function
}
这是在 servicenow 中生成 html 的方式:
<span ng-switch-default="true" class="ng-scope">
<!-- ngIf: !field.max_length || 256 > field.max_length -->
<input ng-model="field.stagedValue" ng-change="stagedValueChange()"
maxlength="" autocomplete="off" name="IO:5cdafd764f02030007b03fb28110c70b"
id="sp_formfield_IO:5cdafd764f02030007b03fb28110c70b" data-type="string"
placeholder="" ng-if="!field.max_length || 256 > field.max_length"
class="form-control ng-pristine ng-untouched ng-valid ng-scope ng-empty ng-
valid-maxlength" ng-model-options="{allowInvalid: true}" ng-
disabled="field.isReadonly()" aria-invalid="false"><!-- end ngIf:
!field.max_length || 256 > field.max_length --><!-- ngIf: field.max_length
>= 256 --></span>
【问题讨论】:
标签: javascript jquery angularjs servicenow