Including Moment.js in LiveCycle Designer

自古美人都是妖i 提交于 2019-12-12 04:49:04

问题


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.

We've used an older version (1.7.2) without any problems but now I only get a 'Function not exist' error.

Does anyone have any expierience with this?

Thanks in advance.


回答1:


How to include Moment.js in an Adobe LiveCycle Form:

  1. Download the minified script
  2. In LiveCycle Designer open your form and create a Script Object called 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:
  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:

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

Now your MOMENTJSMIN script object is set up to provide Moment.js to scripts throughout your form.

To use Moment.js in any of your script, start your script object or event script with this line:

var moment = MOMENTJSMIN.getMomentJS();

Now you can use moment() anywhere in the script that starts with that line. 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()));



回答2:


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.)
  • Check the script referencing. Right path? Right name?
  • Check if the function really exists
  • Check function parameters.


来源:https://stackoverflow.com/questions/26587484/including-moment-js-in-livecycle-designer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!