Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround to get this working when placing scripts in the head of the page #54

Open
ahoiroman opened this issue Jun 15, 2017 · 7 comments

Comments

@ahoiroman
Copy link

Hello,

I am working on including your great script to an extension for a CMS.

This CMS allows me to add JS and CSS - but always to the heading of the page.

If I do $(function() {$('p').selectionSharer();}); the popover appears and lets me share via twitter and mail - but the script does not recognize the Facebook App tag.

As I can not hack the CMS, I have to find a workaround for this script.

Any help is highly appreciated.

@shri3k
Copy link
Collaborator

shri3k commented Jun 22, 2017

@SPQRInc Do you happen to have <meta property="fb:app_id" content="<your_facebook_id_here>" /> in your page?

@ahoiroman
Copy link
Author

Yes. This is my header:

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="canonical" href="http://127.0.0.1:8080/index.php/">
    <meta property="twitter:card" content="summary_large_image">
    <meta property="fb:app_id" content="123456789">
    <meta property="og:site_name" content="Pagekit">
    <meta property="og:title" content="Home">
    <meta property="og:description" content="Globale Meta">
    <meta property="og:url" content="http://127.0.0.1:8080/index.php/"> 

@shri3k
Copy link
Collaborator

shri3k commented Jun 22, 2017

Let's try this.
Let's try adding:

$(function() {
  console.log($('meta[property="fb:app_id"]').attr("content"));
  $('p').selectionSharer();
});

instead of just

$(function() {$('p').selectionSharer();});

and see if it prints 12345679 (or your facebook app_id) in the console. If it does then we'd need to further troubleshoot to see what's going on however if it does not then that would tell us that you're invoking the $('p').selectionSharer() function prior to you having <meta property="fb:app_id" content="123456789"> on your page.

If you don't mind me asking is your CMS a SPA or fully server-side rendered site?

@12aleksandr12
Copy link

Hello. I have a similar situation. Сode

$(function() {
console.log($('meta[property="fb:app_id"]').attr("content"));
$('p').selectionSharer();
});

added, fb:app_id displayed in the console. But the selected text does not fall into facebook

@shri3k
Copy link
Collaborator

shri3k commented Nov 23, 2017

@12aleksandr12 did you mean something similar to this?

@12aleksandr12
Copy link

12aleksandr12 commented Nov 23, 2017

thanks, figured out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@shri3k @12aleksandr12 @ahoiroman and others