• Home
  • Categories
  • Recent
  • Popular
  • Top
  • Tags
  • Users
  • Groups
  • Documentation
    • Home
    • Read API
    • Write API
    • Plugin Development
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
v3.5.2 Latest
Buy Hosting

Javascript HTML Widget

Scheduled Pinned Locked Moved Technical Support
9 Posts 3 Posters 2.7k Views
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Michael PfaffM Offline
    Michael PfaffM Offline
    Michael Pfaff Gamers
    wrote on last edited by Michael Pfaff
    #1

    I'm trying to use the Facebook like plugin on my forum. I put the required Javascript in an HTML widget for Global Header and the Like button code in an HTML widget for Global Footer. It works fine if I use F5 to refresh the page, but then if I navigate to a new page or back to the home page, it goes away.

    Site: https://community.nerdlouisville.org

    What am I doing wrong?

    Thanks for any help!

    1 Reply Last reply
    0
  • yariplusY Offline
    yariplusY Offline
    yariplus Community Rep
    wrote on last edited by
    #2

    Wrapping your script in ajaxify:end should fix this.

    $(window).on('action:ajaxify.end', function () {
      // Your FB code...
    });
    
    1 Reply Last reply
    0
  • julianJ Offline
    julianJ Offline
    julian GNU/Linux
    wrote on last edited by
    #3

    @Michael-Pfaff Hey, looks like you got it working 😄

    Nice site, looks a lot like our community forum 😆

    Michael PfaffM 1 Reply Last reply
    1
  • Michael PfaffM Offline
    Michael PfaffM Offline
    Michael Pfaff Gamers
    wrote on last edited by
    #4

    @yariplus When I put that it doesn't do anything and actually just shows up as text on the page.

    @julian It looks great when you first visit site. But if you navigate away and then back to main page (or any page) it goes away. Odd.

    1 Reply Last reply
    0
  • yariplusY Offline
    yariplusY Offline
    yariplus Community Rep
    wrote on last edited by yariplus
    #5

    @Michael-Pfaff

    Take the js code out of your header widget. Place the code in the Appearance => Custom HTML section of the ACP.

    It should look like this:

    <script>
    
    // FB init code
    (function(d, s, id) {
      var js, fjs = d.getElementsByTagName(s)[0];
      if (d.getElementById(id)) return;
      js = d.createElement(s); js.id = id;
      js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.8&appId=483489128474352";
      fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));
    
    // FB refresh code
    $(window).on('action:ajaxify.end', function () {
      FB.XFBML.parse();
    });
    
    </script>
    

    Also, add the following to the Custom CSS section, to ensure the iframes always get the proper width.

    .fb-like, 
    .fb-like > span,
    .fb-like > span iframe {
      width: 100px !important;
      height: 20px  !important;
    }
    
    1 Reply Last reply
    2
  • Michael PfaffM Offline
    Michael PfaffM Offline
    Michael Pfaff Gamers
    wrote on last edited by
    #6

    Odd. I don't see Custom HTML in the Extend section. Just Plugins, Widgets, Rewards. Is there a plugin I need to install?

    yariplusY 1 Reply Last reply
    0
  • yariplusY Offline
    yariplusY Offline
    yariplus Community Rep
    replied to Michael Pfaff on last edited by
    #7

    @Michael-Pfaff oops, Appearance section!

    1 Reply Last reply
    1
  • Michael PfaffM Offline
    Michael PfaffM Offline
    Michael Pfaff Gamers
    wrote on last edited by
    #8

    @yariplus Golden! And, now I know where the Custom CSS section is! Thank you!

    1 Reply Last reply
    2
  • Michael PfaffM Offline
    Michael PfaffM Offline
    Michael Pfaff Gamers
    replied to julian on last edited by
    #9

    @julian said in Javascript HTML Widget:

    Nice site, looks a lot like our community forum

    Ha! Thanks! Just need some users now! 🙂

    1 Reply Last reply
    1

Copyright © 2023 NodeBB | Contributors
  • Login

  • Don't have an account? Register

  • Login or register to search.
Powered by NodeBB Contributors
  • First post
    Last post
0
  • Home
  • Categories
  • Recent
  • Popular
  • Top
  • Tags
  • Users
  • Groups
  • Documentation
    • Home
    • Read API
    • Write API
    • Plugin Development