DO NOT EDIT. This page has moved to delta docs.
All the frontend communication that happens through JavaScript and needs to obtain data form Solr goes through the SolrUtils library. This library is located in kmaps_engine at the following path:
kmaps_engine/app/assets/javascripts/kmaps_engine/solr-utils.js
We pass the configuration files through a DOM element. Usually, a <div>. For example:
<%= content_tag :div, "", id: 'menu_js_data', data: { term_index: Feature.config.url, asset_index: ShantiIntegration::Source.config.url, feature_id: uid, domain: Feature.uid_prefix, perspective: current_perspective.code, tree: Feature.uid_prefix, features_path: ((defined?(admin) && admin) ? admin_features_path+"/ID" : features_path+"/ID"), mandala_path: "https://mandala.shanti.virginia.edu/APP/ID/REL/nojs", feature_fid: uid, language: Language.current.code } %>
Once we have all the required configuration data, we can obtain that information from JavaScript and initialise our SolrUtils object.
var menuSolrUtils = kmapsSolrUtils.init({
termIndex: $('#menu_js_data').data('termIndex'),
assetIndex: $('#menu_js_data').data('assetIndex'),
featureId: $('#menu_js_data').data('featureId'),
domain: $('#menu_js_data').data('domain'),
perspective: $('#menu_js_data').data('perspective'),
tree: $('#menu_js_data').data('tree'), //places
featuresPath: $('#menu_js_data').data('featuresPath'),
});
Notice that the data entries in JavaScript have been changed form snake_case to camelCase
To see a full example check the implementation of the flyout tree and typeahead. It is located in KMaps Engine under the partial _menu.html.erb.