Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Usage

Add the script tag to head and use the library after the dom is ready

Code Block
languagehtml
<html>
<head>
  <script src="https://dev-meglerpakke.ambita.com/package/mflex.umd.js" charset="utf-8"></script>
</head>
<body>
  <h1>
    Welcome to Ambita Infoland components!
  </h1>
  <div id="search" style="height: 75px"></div>
  <div id="product-list"></div>
  <button id="confirm">Confirm order</button>

  <script>
    document.addEventListener('DOMContentLoaded', () => {
      window.Ambita.mFlex.init({
        environment: 'beta',
        token: {
          access_token: '6d5335cf74246ace-2118f71f-4639423f-a4fe951a-055df547a8cc8a9816a3319a',
          token_type: 'Bearer',
          expires_in: 3600,
          refresh_token: '2478124480194947-a38773f6-49e647f6-986092ca-454f200ce74b66803abb7686',
          scope: ['infoland.mflexflex', ...],
          expires_at: '2022-09-21T1127T07:5047:1349.486Z774Z'
        },
        reference: 'test'
      });

            window.Ambita.mFlex.search.onSearchResult = (result) => {
        console.log(result);
      };

            window.Ambita.mFlex.search.load('#search');
     

      window.Ambita.mFlex.productList.load('#product-list', {
        share:{},
        cadastre:{
          knr: '0301',
          gnr: '224',
          bnr: '64',
          snr: '18'
        }
      });


           const confirmButton = document.getElementById('confirm');
      confirmButton.addEventListener('click', async () => {
        const orderNumber = await window.Ambita.mFlex.productList.confirmOrder();
       

        console.log(orderNumber);
      });
    });
  </script>
</body>
</html>

See Usage for more information about how to use the init and load functions.