[英]Dynamics CRM 2015: How do I get a Web Resource button I created to reference a function in a Javascript Library I added to the form?
I have a button I put onto the form with the code 我有一个放在代码上的按钮
<button type="button" onclick="btnCalculate_onClick();">test</button>
And I have a function called btnCalculate_onClick()
inside a Library I added to the form with the name dc_btnAutofillAddress. 我在库中添加了名为
btnCalculate_onClick()
的库中有一个名为btnCalculate_onClick()
的函数。 The function uses jQuery, but I also have a jQuery library added to the form. 该函数使用jQuery,但我还向表单添加了一个jQuery库。
How would I make it so if I click the button, it calls the btnCalculate_onClick()
function when it's clicked? 如果单击该按钮,单击该按钮,它将调用
btnCalculate_onClick()
函数,该怎么做? I tried the code below and it doesn't work. 我尝试了下面的代码,但它不起作用。
<html>
<head>
<script type="text/jscript" src="dc_btnAutofillAddress"></script>
</head>
<body style="word-wrap: break-word;">
<button type="button" onclick="btnCalculate_onClick();">test</button>
</body>
</html>
From a web resource, you can reference the form by doing using window.parent. 从Web资源中,您可以通过使用window.parent来引用表单。 So:
所以:
<button type="button" onclick="parent.btnCalculate_onClick();">test</button>
Just make sure that, in the form editor, the web resource's option to "Restrict cross-frame scripting" is unchecked. 只要确保在表单编辑器中未选中Web资源的“限制跨框架脚本”选项即可。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.