2

I have created 3 SPFx web parts which are fine when I test them individually. But if I keep all of them on the page then issues are coming, because of jQuery loading. All three are using jQuery file. 2 out of 3 are using third party plugins which are dependent on jQuery. Unfortunately one of the web part is not working since jQuery is loading twice so third party plugin is not able to identify jQuery. plugin functionality not working. To overcome this i have used with SPComponentLoader function.

public render(): void {        
    if(typeof(window['jQuery'])=='undefined'){
      SPComponentLoader.loadScript('https://code.jquery.com/jquery-3.2.1.min.js',{ globalExportsName: 'jQuery' }
    ).then(($: any) => {
      this.jQuery=$;
      //debugger;      
      require('MySlider');
      this.initProcess()
    });
    }
    else{
      this.initProcess();
    }
  }

How to fix this?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.