简体   繁体   English

在LiveCycle Designer中包括Moment.js

[英]Including Moment.js in LiveCycle Designer

For few days I've been trying to include the actual Moment.js library in my dynamic PDF which I've created with Adobe Livecycle Designer. 几天来,我一直在尝试使用Adobe Livecycle Designer创建的动态PDF中包含实际的Moment.js库。

We've used an older version (1.7.2) without any problems but now I only get a 'Function not exist' error. 我们使用了较旧的版本(1.7.2),没有任何问题,但是现在我仅收到“功能不存在”错误。

Does anyone have any expierience with this? 有人对此有任何经验吗?

Thanks in advance. 提前致谢。

How to include Moment.js in an Adobe LiveCycle Form: 如何在Adobe LiveCycle表单中包含Moment.js:

  1. Download the minified script 下载缩小的脚本
  2. In LiveCycle Designer open your form and create a Script Object called MOMENTJSMIN 在LiveCycle Designer中,打开表单并创建一个名为MOMENTJSMIN的脚本对象。
  3. Copy the minified script into that Script Object 将缩小的脚本复制到该脚本对象中
  4. In the Script Editor window of LiveCycle Designer, edit MOMENTJSMIN Script Object in the following manner: 在LiveCycle Designer的“脚本编辑器”窗口中,按以下方式编辑MOMENTJSMIN脚本对象:
  5. Remove all the script up to but not including the second curly brace { : 删除所有脚本,直到但不包括第二个花括号{:

     !function(a,b){"object"==typeof exports&&"undefined"!=typeof module?module.exports=b():"function"==typeof define&&define.amd?define(b):a.moment=b()}(this,function() 
  6. Remove the rounded parenthesis and semicolon from the end of the minified script 从缩小的脚本的末尾删除圆括号和分号

  7. Add this line to the beginning of the minified script: 将此行添加到缩小脚本的开头:

     if (xfa.momentjs == undefined) xfa.momentjs = function() 
  8. In the MOMENTJSMIN Script Object add this function after the end of the script: 在MOMENTJSMIN脚本对象中,在脚本结束后添加以下函数:

     function getMomentJS(){ return xfa.momentjs(); } 

Now your MOMENTJSMIN script object is set up to provide Moment.js to scripts throughout your form. 现在,您的MOMENTJSMIN脚本对象已设置为在整个表单中向脚本提供Moment.js。

To use Moment.js in any of your script, start your script object or event script with this line: 要在任何脚本中使用Moment.js,请使用以下行启动脚本对象或事件脚本:

var moment = MOMENTJSMIN.getMomentJS();

Now you can use moment() anywhere in the script that starts with that line. 现在,您可以在脚本中以该行开头的任何地方使用moment()。 eg: 例如:

var moment = MOMENTJSMIN.getMomentJS();
var jan07 = moment([2007, 0, 29]);
app.alert(moment().format("dddd, MMMM Do YYYY, h:mm:ss a"));
app.alert(jan07.format("dddd, MMMM Do YYYY") + " was " + jan07.fromNow());
app.alert(moment.isDate(new Date()));

What I would check first: 我首先要检查的是:

  • Make sure your script is fully loaded before trying to invoke functions from it. 在尝试从脚本中调用函数之前,请确保脚本已完全加载。 (check the event, where you call the function-calculate, form:readty etc.) (检查事件,在其中调用函数计算,form:readty等。)
  • Check the script referencing. 检查脚本引用。 Right path? 正确的道路? Right name? 正确的名字?
  • Check if the function really exists 检查功能是否确实存在
  • Check function parameters. 检查功能参数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM