Any ideas why I'm only getting 0 or false, but never true for result.get_value()?
// Set IsFollowed correctly.
var clientContext = SP.ClientContext.get_current();
var socialManager = new SP.Social.SocialFollowingManager(clientContext);
var socialActor = new SP.Social.SocialActorInfo();
socialActor.set_contentUri(url);
socialActor.set_actorType(SP.Social.SocialActorType.site);
result = socialManager.isFollowed(socialActor);
clientContext.executeQueryAsync(
function () {
if (result.get_value())
{
this.IsFollowed = ko.observable(true);
}
else
{
this.IsFollowed = ko.observable(false);
}
//alert("IsFollowed = " + this.IsFollowed);
},
function (sender, args) {
// Failed.
alert('Error: ' + args.get_message());
}
);
I am doing the above when pushing to an observablearray in knockout.js, and wait for the social manager to load:
SP.SOD.executeFunc('sp.js', 'SP.ClientContext', function () {
// Make sure SocialFollowingManager is available
SP.SOD.executeFunc('userprofile', 'SP.Social.SocialFollowingManager',
function () {
//ko.applyBindings(new LinksViewModel(), document.getElementById("springim-core-menu-list-links"));
ko.applyBindings(new MyQuickLinksViewModel(), document.getElementById("springim-myquicklinks"));
ko.applyBindings(new MyFollowedSitesViewModel(), document.getElementById("springim-core-menu-list-followedsites"));
});
});
Oddily enough, I use the same code elsewhere when the page has loaded on a click event and it reads the value correctly (just true/false).
Regards,
Ben