Notifications

400 views

Description

A code (such as a function) that is defined in the client script part of an UI Page is not being invoked if the UI page itself is called from an UI page type variable in a catalog item/record producer.

Steps to Reproduce

  1. Create a UI page with the following values:

    HTML:

    <?xml version="1.0" encoding="utf-8" ?>
      <j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
      <button onclick="myFunction()">Click me</button>
    </j:jelly>

    Client script:

    function myFunction() {
    alert("Function triggered"); }
  2. Open any catalog item and create a new variable for it with the following values:

    • Type: UI Page
    • UI page: the UI page created earlier
  3. Click the Try It button on this catalog item and click on the button that appears on the page.

    Note that instead of returning a pop-up alert message and a message appears in the browser console: "myFunction is not defined".

 

Workaround

Move the code from the client script field part into the HTML field part of the UI page.

For example:

Original values:

HTML:

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<button onclick="myFunction()">Click me</button>
</j:jelly>

Client script:

function myFunction() {
alert("Function triggered");
}

Moved values:

HTML:

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<button onclick="myFunction()">Click me</button>

Client script:

function myFunction() {
alert("Function triggered");
}
</script>
</j:jelly>

Related Problem: PRB1296896

Seen In

There is no data to report.

Associated Community Threads

There is no data to report.

Article Information

Last Updated:2018-10-10 13:32:32
Published:2018-08-10