M
M
Marcel Markhabulin2012-02-01 19:08:56
JavaScript
Marcel Markhabulin, 2012-02-01 19:08:56

Updating information in the Vkontakte like button

There is a page. At the first loading by AJAX, all necessary data is filled in and VK.Share.button is initialized. In the future, the information is updated, and the sharing information in the button remains the same as it was at initialization.

In this regard, the question is: how can you initialize a new one? Great - with the help of some kind of call to VKontakte. Or completely bang all initialized scripts with content with re-initialization.

Scheme of the test page:
div class="..." onclick="return VK.Share.click(0, this);">img src="somepicrure.png" alt="">/div>- by clicking on this custom layer, the sharing window is called

div id="vk_share_button">1/div>- an invisible button. Vkontakte scripts fill in all their parameters in it. Task: somehow, in parallel with ajax update, update the sharing button with new temp and temp2 values

function vk_delay() {
$(document).ready(function() {
// получение каких-то параметров со страницы
document.getElementById('vk_share_button').innerHTML = VK.Share.button({
url: "ссылка с параметрами"+temp+temp2,
title: ""+temp+temp2+"",
description: "...",
image: '...',
noparse: 'true'
},{
type: "button",
text: "Сохранить",
title: "..."
});
});

}

function create_vk() { setTimeout("vk_delay()", 1000); } // костыльчик, ибо вк инициализируется раньше, чем ajax выдаст данные на страницу
create_vk();



Smoking manuals did nothing. The repeated call of the button rendering function did not lead to anything, as well as with the preliminary clearing of the contents of the vk_share_button layer.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Marcel Markhabulin, 2012-02-24
@milar

The issue has not yet been resolved. Another option for a crutch solution: insert a like button on a separate page and display it as an iframe. Call iframe reload on ajax update. But the solution is terribly hacky and creates layering issues when applying layers on top of a called iframe

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question