Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Popup Callback #3

Open
shaneonabike opened this issue Feb 2, 2024 · 0 comments
Open

Custom Popup Callback #3

shaneonabike opened this issue Feb 2, 2024 · 0 comments

Comments

@shaneonabike
Copy link

Hey there,

Thanks for building a great extension. I don't think I fully understand what scope the popup_callback is calling functions from.

I keep getting an error ReferenceError: depotDisplay is not defined when I don't make it a global function. But given that I want to use CiviCRM's api I'm stuck doing

function($) {
function displayInfo(feature, layer) {
var text = 'hello';
     if (feature.properties.depot_id) {

       text = 'some stuff';

CRM.api4('Contact', 'get', {
  select: ["display_name", "custom_distribution_schedule.Days_of_a_the_Week:label", "custom_distribution_schedule.Start_Time", "custom_distribution_schedule$
  join: [["Relationship AS relationship", "LEFT", ["relationship.contact_id_b", "=", "id"], ["relationship.contact_id_a", "=", 345]], ["Custom_Distribution_$
  where: [["relationship.relationship_type_id", "=", 15], ["relationship.is_active", "=", true]],
  checkPermissions: false, // IGNORED: permissions are always enforced from client-side requests
  limit: 1
}).then(function(contacts) {
  text = contacts[0].display_name;

  // do something with contacts array
}, function(failure) {
  // handle failure
});

       // Find the details

//       layer.bindPopup(text);
     }
    layer.bindPopup(text);
};


}(CRM.$);

Unless you feel that I'm doing this wrong? Any help would be amazing I'm so close to finishing the integration, but I'm stuff on this element.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant