selection-sharer
selection-sharer copied to clipboard
Workaround to get this working when placing scripts in the head of the page
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.
@SPQRInc Do you happen to have <meta property="fb:app_id" content="<your_facebook_id_here>" />
in your page?
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/">
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?
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
@12aleksandr12 did you mean something similar to this?
thanks, figured out.