Create a view with a leaflet map display and an exposed filter with a default value. Ensure "use ajax" is set and the leaflet setting "hide if empty" is set. If the default exposed filter yields no results it all appears okay (ie. no map). If you change the exposed filter to a value that produces results an empty white space appears where the map would go. If, however, the default exposed filter yields at least one result, the map displays fine on initial load. Toggling then to another exposed filter value continues to work just fine. I can get around this by not ticking "hide if empty" but then I get a grey box where the map belongs.
I noticed that the following files aren't initially loaded if the map doesn't display.
- leaflet.css
- leaflet.js
- leaflet.drupal.js
Which means libraries_load('leaflet');
is not being called initially, and probably not called on the ajax reload.
Is there a way to ensure the ajax load will load the leaflet library? If not, can we have a checkbox on the view to load the leaflet library regardless if there is a result or not?
Comment | File | Size | Author |
---|---|---|---|
#1 | leaflet-2400301-ajax_load_libraries.patch | 2.11 KB | mstrelan |
Comments
Comment #1
mstrelan CreditAttribution: mstrelan commentedComment #2
Steve Polito Design CreditAttribution: Steve Polito Design commentedI applied this patch, but am still not able to display a map if there are initially no results.
Comment #3
anewholm CreditAttribution: anewholm as a volunteer commentednote that this is an issue also if there are Required Filters and AJAX.
Comment #4
jmev CreditAttribution: jmev commentedI see the issue mentioned in #3 as well. In fact, it appears that running exposed filters for valid results only works the first time, with subsequent attempts to run an altered filter doesn't do anything. I get the feeling ajax isn't behaving correctly. I'm needing to provide a solution son so I may need to drop ajax, as I can at least run a no-results redirect from the template file at that point, but when ajax is enabled, I get ajax errors, killing the execution of my code.