Closed neffets closed 9 years ago
Let me see if I understood your question. You replaced the old socialshare-privacy code with Shariff.
The socialshare-privacy documentation recommended using the script tag inside the <head>
of your document.
In contrast to that, Shariff must be included right before the (closing) </body>
tag to work. Have you followed that instruction?
Yes,
if I would have an <div class="shariff"></div>
it would work that way.
My problem is,
1) that the html-code has no class="shariff", i have an id=socialshare
2) I want enable the Share-Buttons later, not at body-end, but only after dom-ready
Solution could be: 1) on dom-ready I add with javascript the class=shariff to my div-with-id Now comes problem 2 2) dom-ready ist later then body-end, I now want to trigger the shariff-code later, or better I want to give my $('#socialshare') as object to Shariff to paint the share-buttons there
Embedding Shariff is difficult in your situation (not a node project, no .shariff
element).
Try something like this:
<head>
$(function() {
$("#socialshare").addClass("shariff");
$.getScript("/path/to/shariff.js");
});
</head>
In my opinion modifying the HTML document is the best option.
We had a problem using this too recently. Our project was also not a node project.
We had need to initialize the shariff code after it was loaded on to the page, to allow for later ajax'd content to include the sharing functionality. The way we fixed this was to assign the _Shariff function to the window object. This allowed us to call as and when we needed.
Is this something you could add to this project to allow the plugin to be used in this way as well?
Just pushed a change that renames _Shariff
to Shariff
and that exports the Shariff
class to the global
(window
) object:
This example html page shows how to initialize shariff after it was loaded:
https://github.com/heiseonline/shariff/blob/master/demo/custom-initialization.html
The change is not released yet.
Looks great. Any idea when this might be released?
Today or tomorrow.
Perfect. Thanks for the update.
Our pages include as a tag
<div id="socialshare"></div>
(from former socialshare-privacy plugin). Before we could use after dom-ready a javascript-call:Now all is encapsulated as anonymous functions.
How we can call it now at a later like any othe jquery-plugin
Not working was the initial code:
How we can call the _Shariff function from extern javascript in a normal html-page (not a node-app)?