T
T
TM_ID2014-07-24 03:22:00
Ruby on Rails
TM_ID, 2014-07-24 03:22:00

How to make Pluso social share buttons work with turbolinks Rails?

Tried different ways, like these:

$(document).on('ready page:load', function () {

});

var ready;
ready = function() {

};

$(document).ready(ready);
$(document).on('page:load', ready);

But this does not solve the problem of turbolinks.
Button code:
(function() {
  if (window.pluso)if (typeof window.pluso.start == "function") return;
  if (window.ifpluso==undefined) { window.ifpluso = 1;
    var d = document, s = d.createElement('script'), g = 'getElementsByTagName';
    s.type = 'text/javascript'; s.charset='UTF-8'; s.async = true;
    s.src = ('https:' == window.location.protocol ? 'https' : 'http')  + '://share.pluso.ru/pluso-like.js';
    var h=d[g]('body')[0];
    h.appendChild(s);
  }})();
<div class="pluso" data-background="#ebebeb" data-options="big,square,line,horizontal,counter,theme=04" data-services="vkontakte,odnoklassniki,facebook,twitter,google,moimir,email,print"></div>

Tell me how to be?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Snegirev, 2014-07-24
@TM_ID

if (window.pluso)if (typeof window.pluso.start == "function") return;

it is immediately clear that if window.pluso exists, then do nothing.
I can suggest rewriting the code so that in page:receive, all pluso elements written to window are cleared:
$(document).on("page:receive", function(){
  window.pluso = null;
  window.ifpluso = null;
});

Refusal of turbolinks is clearly not a solution to this issue, since the header says "with turbolinks"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question