I'm trying to implement Facebook functionalities into my application. The first functionality was being able to login use facebook. The second one to allow the user to import friends from facebook into the application.
The problem is however that when I'm using the FB API the JQuery Mobile functionalities stop.
The layout works perfect if I remove the Facebook API code. This means that if I add a fieldset with the data-role set to controlgroup, none of the JQuery Styles and function are applied to the element and its children.
Does anyone know a solution for this problem? (There should be more JQuery Mobile apps making use of the social API).
Controller.js
this.handleContactsFacebook = function () {
this.initialize();
function retrieveContacts () {
FB.api('/me/friends/?fields=id,first_name,middle_name,last_name,username,name', function(response) {
(new Contact()).showContactListFacebook(response.data);
});
}
FB.getLoginStatus(function (data) {
if (data.status === 'connected') {
retrieveContacts();
}
else if (data.status === 'not_authorized') {
$.mobile.changePage("menu.html");
}
else {
$.mobile.changePage("menu.html");
}
});
};
contact.js
this.showContactListFacebook = function (contacts) {
var fieldset = $("<div data-role=\"fieldcontain\">" +
"<fieldset data-role=\"controlgroup\">" +
"<legend>Agree to the terms:</legend>" +
"<input type=\"checkbox\" name=\"checkbox-1\" id=\"checkbox-1\" class=\"custom\" />" +
"<label for=\"checkbox-1\">I agree</label>" +
"</fieldset>" +
"</div>");
$("fieldset").remove();
$("#contactsFacebook").prepend(fieldset);
};
http://forum.jquery.com/topic/jquery-mobile-ignored-data-role-when-implementing-facebook