Closed confile closed 11 years ago
Have you tried jquery HTML5 data method ?
Ex.: $('#myShareLink').data('to')
You cannot apply this, if you have, as usual, a list of friends. Consider a list of friends, where each list itam has a sendLink button. Then you cannot determine what is the correct fried uuid?
Sorry, I do not have much time to dig into this, but you should be able to get a reference to the link (with response.target
?)
Since, this is not linked to Grails Facebook SDK but to JS/jQuery, I close this issue.
@benorama response.target gives undefined. I am woundering if this is an issue with you plugin?
Here is the code which is executed (in web-app/js/send-link.js):
FB.ui(options, function(response) {
if (link.data('callback') != undefined) {
var callback = window[link.data('callback')];
if (typeof callback === 'function') {
callback(response);
}
}
});
So you might try to edit it to add a second parameter link
to the callback function.
FB.ui(options, function(response) {
if (link.data('callback') != undefined) {
var callback = window[link.data('callback')];
if (typeof callback === 'function') {
callback(response, link);
}
}
});
Then in your gsp
function someCallbackFunction(response, link) {
alert('callback called! Message to:' + link.data('to'));
if (response && response.success) alert('Sent successfully');
}
Let me know if it solves your issue.
Your solution might be more elegant. I solve it in a different way. I hide the sendLink and had another element with a click handler on the page. When I click this element I store the ui in a hidden input field and trigger the click command on sendLink. This way the callback can access the hidden input and gets the uid of the clicked facebook user.
How can I access the friends facebook id in the callback function? If I cannot get the friend id in the callback function I cannot react on it. I tried to get attribute properties with $(this).attr() but this does not work.