Code Monkey home page Code Monkey logo

Comments (6)

OlivierCC avatar OlivierCC commented on June 18, 2024 2

Hi @sidjustsid,

This can happened when you are using two different WebParts on the same page that include a JQuery plugin. In fact the SPFx will reload JQuery and randomly the JQuery plugin will fail to load.

Today the only dirty fix that I found is to use the custom version of JQuery included in the latest 1.0.3 package or at this address: http://spfx40fantastics.azureedge.net/spfx40fantastics/jquery_510295b52d8a7cc774bf4fb013893d1e.js

Regards,

Olivier

from spfx-40-fantastics.

kmarwen avatar kmarwen commented on June 18, 2024

Hi @OlivierCC
would you please tell us what's the prob with Jquery and it's plugins in those webparts ?
I'm cloning your webparts and facing same problems with jquery
merci

from spfx-40-fantastics.

kmarwen avatar kmarwen commented on June 18, 2024

I see the diff with jquery
you added

if (window.jQuery)
		return;

that correct the behavior of jquery plugins ?

from spfx-40-fantastics.

kmosti avatar kmosti commented on June 18, 2024

I followed @OlivierCC advice, and replaced the jquery minified file at node_modules/jquery/dist/jquery.min.js - which solved the loading issue.

However, this exposed a different (unrelated?) issue, unitegallery does not seem to handle loading different themes on the same page.

To reproduce:

  1. Replace the jQuery file
  2. Add two web parts using the unitegallery library (I used Grid gallery and Tiles Menu)
  3. First load might seem OK:
    image
  4. Subsequent reload of the page exposes the issue:
    image

Fix:

  1. Replace the jQuery file per @OlivierCC instructions
  2. Set the theme in the unitegallery options, for my use case, that meant modifying the options (line 114) of TilesMenuWebPart.ts:
private renderContents(): void {
      ($ as any)("#" + this.guid + "-gallery").unitegallery({
        gallery_theme: "tiles",
        tile_as_link: true,
        tiles_type: this.properties.justified === true ? "justified": '',
        tile_enable_icons: this.properties.enableIcons,
        tile_enable_textpanel: this.properties.textPanelEnable,
        tile_textpanel_always_on: this.properties.textPanelAlwaysOnTop,
        tile_textpanel_position: this.properties.textPanelPosition,
        tile_textpanel_bg_opacity: this.properties.textPanelOpacity,
        tile_textpanel_bg_color: this.properties.textPanelBackgroundColor,
        tile_textpanel_title_font_family: this.properties.textPanelFont,
        tile_textpanel_title_font_size: this.properties.textPanelFontSize != null ? this.properties.textPanelFontSize.replace("px", "") : '',
        tile_textpanel_title_text_align: this.properties.textPanelAlign,
        tile_textpanel_title_color: this.properties.textPanelFontColor,
        tiles_space_between_cols: this.properties.spaceBetweenCols,
        tile_enable_border: this.properties.enableBorder,
        tile_border_width: this.properties.border,
        tile_border_color: this.properties.borderColor,
        tile_enable_shadow: this.properties.enableShadow
      });
  }

from spfx-40-fantastics.

kmarwen avatar kmarwen commented on June 18, 2024

Hi @kmosti
try adding another webparts (tiles, animated text, ...) and reload many times the page you'll see js errors in console
till today I don't understand the cause of this issue with jquery

from spfx-40-fantastics.

kmosti avatar kmosti commented on June 18, 2024

I'll give it a try, but for now my web parts are a little bit healthier so that makes me happy :)

What kinds of errors are you seeing in the console?

from spfx-40-fantastics.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.