You're almost there! Please answer a few more questions for access to the Applications content. Complete registration
Interested in joining? Complete your registration by providing Areas of Interest here. Register

Import external Javascript in VBCS

edited Jan 4, 2021 3:27PM in Visual Builder 8 comments

Summary

Import external Javascript in VBCS

Content

Hi,

I want to use JS (https://lindell.me/JsBarcode/) to generate bar code.

As per docs: https://lindell.me/JsBarcode/, we need to import JS and call function.

I have imported JS under Resources/js folder.  I have attached code of how i am invoking the function on button click.

However i am getting error as: JsBarcode is not a function. Any hint where am i going wrong?

Code Snippet

define(["resources/js/JsBarcode.all.min.js"], function(JsBarcode) {
  'use strict';

  var PageModule = function PageModule() {};

   PageModule.prototype.generateBarCode = function () {
   return JsBarcode("#barcode", "Hi!");
  }; 

  return PageModule;
});

Howdy, Stranger!

Log In

To view full details, sign in.

Register

Don't have an account? Click here to get started!