Home Analyst Portal

custom.js... Request Offering Pages, "'Require' is undefined"

Adrian_PaechAdrian_Paech Customer Advanced IT Monkey ✭✭✭

Hi all,

On all advanced request offering forms, I am trying to encourage users to update their contact information (see example below which appears on RHS of ARO form).

The issue I am having is when they click "edit my contact details", and the code attempts to load the popup window to allow end-users to edit their contact details.

This works perfectly fine on the incident and service request forms, but not the request offering forms.

At the point where the custom.js code tries to load the "EditUserDetails" template form, I get the error "'require' is undefined"

Example snippit code:

 //Load Form to Update User Properties
 function loadTemplate (objUser, htDropDownData, userPickerId) {
        //use requires to load the HTML template first       
  require(["text!/CustomSpace/Custom_UpdateUserDetails/ext_EditUserDetails_template.html"],
            function (htmlTemplate) { 
              etc. etc. etc.

 Even when I attempt to pre-load "\Scripts\require.js", it seems to load ok, but then I get other errors.

I gather require.js is not properly initialised under the request offering part of the portal.
Is there any way to rectify this / get require.js loaded properly for the ARO part of the portal?

Pic of "Edit My Contact Details" example.

Thanks in advance.

Regards,

Adrian

Best Answer

Answers

  • Martin_BlomgrenMartin_Blomgren Customer Ninja IT Monkey ✭✭✭✭
    edited January 2017
    Hi Adrian,

    When you load require.js it's probably loaded asynchronously with an ajax call, could the reason for the errors be that require.js isn't fully initialized yet?

    If you put your code into the success callback from the ajax request which loads require.js does it work then?
    $.getScript("/Scripts/require.js", function() {<br>&nbsp;&nbsp;&nbsp; // code here<br>&nbsp;&nbsp;&nbsp; ....<br>};

  • Adrian_PaechAdrian_Paech Customer Advanced IT Monkey ✭✭✭

    Thanks for the tip.

    Its getting further (now initiating the require.js script), but is still erroring out within the require.js.

    SCRIPT5022: Script error for: text
    http://requirejs.org/docs/errors.html#scripterror
    File: eval code (29), Line: 13, Column: 97

    when I navigate to the link above, it reads..

    Script error§ 7

    This occurs when the script.onerror function is triggered in a browser. This usually means there is a JavaScript syntax error or other execution problem running the script. To fix it, examine the script that generated the error in a script debugger.

    This error may not show up in IE, just other browsers, and instead, in IE you may see the No define call for ... error when you see "Script error". This is due to IE's quirks in detecting script errors.

    Weird really, as it works from incident / servicerequest js... but confused why we are getting these errors. :-/

    Adrian

  • james_kleinschnitzjames_kleinschnitz Cireson Dev, Product Owner Advanced IT Monkey ✭✭✭
    It is really hard to help here without seeing all the code, especially with this in the error description:
    This usually means there is a JavaScript syntax error or other execution problem running the script.

  • Adrian_PaechAdrian_Paech Customer Advanced IT Monkey ✭✭✭

    Hey James.

    Essentially I all I am trying to do is load a kendo popup input form, within any request offering page upon clicking on a button (edit my contact details).

    aka.

     function loadTemplate (objUser, htDropDownData, userPickerId) {
            //use requires to load the HTML template first       
      require(["text!/CustomSpace/Custom_UpdateUserDetails/ext_EditUserDetails_template.html"],
                function (htmlTemplate) {

    Very simple.

    And that's when I get the require error.

    If you have a go at trying to use require within the request offering page, you will get the same error.

    Regards,

    Adrian

  • Adrian_PaechAdrian_Paech Customer Advanced IT Monkey ✭✭✭

    This worked perfectly!

    Thanks Martin, much appreciate your assistance with this workaround :)

    Cheers,

    Adrian

Sign In or Register to comment.