Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-78404

Fragment's Javascript Section does not support Function usage

    Details

      Description

      Description:
      Currently, the Fragments's Javascript section gets encapsulated within a function. This is likely to prevent unwanted interactions with the rest of the page, but prevents functions from working properly from the Javascript sectionr. However, if a user wants to be able to use functions to dynamically interact with the page, they would have to include the Javascript within <script> </script> tags in the HTML section. This makes the Javascript section obsolete as the user will likely include <script> tags inside the HTML and ignore the JS section.

      Steps to Reproduce:

      1. Log onto Liferay as test@liferay.com
      2. Navigation to Site Administration > Content > Fragments
      3. Create a Collection, Click on it, then create a Fragment
      4. Add HTML/CSS/JS

      HTML:
      <div class="fragment_36759">
      <div id="test">
      Hello
      </div>
      <button type="button" onclick='testFunction()'>Click Me
      </button>
      </div>

      CSS:
      .fragment_36759

      { font-size: 50px; }

      JS:
      function testFunction()

      { document.getElementById("test").innerHTML = "Surpise!"; }
      1. Assert that when "Click Me" gets clicked in preview section, Hello changes to Suprise

      Expected Result:
      When "Click Me" gets clicked in preview section, Hello changes to Suprise.

      Actual Result:
      Nothing happens.

      Notes:
      If we were to include the same function in <script> tags and placed it into the HTML directly, the Javascript will correctly work. Also any Non-Function Javascript should work, but only as a static call.

      Reproduced on:
      Tomcat 8.0.32 + MySQL 5.7
      Portal master GIT ID: 325704f3781b99c3c1814e7e43f957460166d052

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  1 year, 17 weeks ago

                  Packages

                  Version Package
                  7.1.0 Beta 2
                  Master