Newer
Older
<div class='crm-label'>Groups</div>
<div class='crm-content'>
var data={crmAPI entity='GroupContact' action='get' sequential=1 contact_id=$contactId};
to avoid creating javascript global variables, wrap them in an anonymous function and assign the parameters from smarty variables on the last line before {/literal}
*}
cj(function($){
if ($(".crm-contact_type_label").length == 0) {
CRM.alert("Someone has changed the summary layout, groups can't be displayed properly");
return;
}
$(".crm-contact_type_label").parent().parent().prepend($("#groups").html());
$("#groups").remove();
var groups=[];
$.each(data.values, function(key) {
groups.push(data.values[key].title);
});
$(".groups .crm-content").html(groups);
({$contactId},
{crmAPI entity='GroupContact' action='get' sequential=1 contact_id=$contactId}
));