AndrewS AndrewS - 9 months ago 44
HTML Question

How to clone any data from a widget with Jquery?

I use a social comments widget for my wesbite, and i want to clone some data from the widget and use it as I want in my template.

To clone the data I use this jQuery code:

var $button = $('#hypercomments_widget').clone(true);

But it does't work.

Please, if this is possible to get done, help me.

Widget code in side HTML:

<div id="hypercomments_widget"></div>
<script type="text/javascript">
_hcwp = window._hcwp || [];
_hcwp.push({widget:"Stream", widget_id: xxxxx});
(function() {
if("HC_LOAD_INIT" in window)return;
HC_LOAD_INIT = true;
var lang = (navigator.language || navigator.systemLanguage || navigator.userLanguage || "en").substr(0, 2).toLowerCase();
var hcc = document.createElement("script"); hcc.type = "text/javascript"; hcc.async = true;
hcc.src = ("https:" == document.location.protocol ? "https" : "http")+"://"+lang+"/widget.js";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hcc, s.nextSibling);


Answer Source

Because you should wait after your plugin loaded fully try to setTimeout() 3 seconds (tested).


so this is a working solution

    var $button = $('#hypercomments_widget').clone(true);
    },3000);//3 seconds