custom.js... Request Offering Pages, "'Require' is undefined"
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
-
Martin_Blomgren Customer Ninja IT Monkey ✭✭✭✭@Adrian_Paech, didn't have the time to do any testing with requireJS but if you want the ability to load a Kendo modal window anywhere you could always do the html inline as a string var in your custom js. I do this successfully for different "Analyst quick actions".
Please see attached working example and adapt to your needs!5
Answers
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?
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
This usually means there is a JavaScript syntax error or other execution problem running the script.
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
Please see attached working example and adapt to your needs!
This worked perfectly!
Thanks Martin, much appreciate your assistance with this workaround
Cheers,
Adrian