Thursday, November 23, 2023

Refer any external JavaScript library in VBCS application

Refer any external JavaScript library in VBCS application


Oracle Visual Builder Cloud Service (VBCS) supports the inclusion of external JavaScript libraries in your applications. This can be useful when you want to leverage the capabilities of a specific library that is not natively provided by VBCS. Here's a general guide on how to refer to an external JavaScript library in a VBCS application:

Steps:

  1. Find and Include the Library:

    • Identify the external JavaScript library you want to use and ensure that it is hosted on a publicly accessible server or CDN (Content Delivery Network).
  2. Add a Custom JavaScript File in VBCS:

    • In your VBCS application, go to the "Scripts" section, and add a new custom JavaScript file. This is where you will write or include the code related to the external library.
  3. Link to the External Library:

    • Inside your custom JavaScript file, add a script tag to link to the external library. For example:

      javascript
      // Example: Linking to jQuery from a CDN var script = document.createElement('script'); script.src = 'https://code.jquery.com/jquery-3.6.4.min.js'; document.head.appendChild(script);
  4. Use the Library in VBCS Components:

    • Once the library is loaded, you can use its functionality within your VBCS components, such as custom JavaScript actions, page-level scripts, or component-level scripts.
  5. Ensure Load Order:

    • Pay attention to the order in which scripts are loaded. If your application depends on the external library, make sure it is loaded before any scripts that rely on its functionality.
  6. Handle Asynchronous Loading (if necessary):

    • Some libraries may be loaded asynchronously. If this is the case, ensure that your VBCS application handles the asynchronous loading appropriately, especially if other scripts depend on the library being fully loaded.

Example: Loading jQuery in a VBCS Application

Let's say you want to use jQuery in your VBCS application. You can follow these steps:

  1. In the VBCS application, go to the "Scripts" section.

  2. Add a new custom JavaScript file (e.g., custom-scripts.js).

  3. Inside custom-scripts.js, include the following code:

    javascript
    // Load jQuery from a CDN var script = document.createElement('script'); script.src = 'https://code.jquery.com/jquery-3.6.4.min.js'; document.head.appendChild(script); // Use jQuery after it is loaded script.onload = function() { // Your jQuery code here // Example: $("body").css("background-color", "lightblue"); };
  4. Save your changes.

This example demonstrates how to load jQuery from a CDN and then use it in your VBCS application. Adjust the code based on the specific library you want to include.

Remember to review the documentation of the external library you are using for any specific instructions or best practices related to its integration. Additionally, always ensure compliance with any licensing or usage terms associated with the external library. 

No comments:

Post a Comment

Oracle Payables New Features By Quarterly Updates

 Oracle Payables New Features By Quarterly Updates https://docs.oracle.com/en/cloud/saas/readiness/erp-all.html https://docs.oracle.com/en/c...