Hi,
I have a template that reads the options for a team from the database and also allows for fixed years (I haven't worked out how to perform 2 separate queries!). It uses these two parameters to update two queries on the page.
I'd like to re-use the same template and have it dynamically load the query based on an input that is defined at the time the page is edited - can you recommend a method that doesn't require me to duplicate the query/template?
Query: select TYPENAME as team FROM QA_OWNER.REL_TYPES
Template I want to re-use with query name(s) defined when the macro is added to the page (i.e. ReleaseCalendar and ReleaseStats are dynamically added)
<form id="my-pocketquery-form" class="aui">
<div class="field-group">
<label for="select-team">Choose Team:</label>
<select class="select" id="select-team" name="select-team">
<option value="%">All</option>
#foreach ($row in $result)
<option value="$row.team">$row.team</option>
#end
</select>
</div>
<div class="field-group">
<label for="select-year">Choose Year:</label>
<select class="select" id="select-year" name="select-year">
<option value="%">All</option>
<option value="2015">2015</option>
<option value="2016">2016</option>
</select>
</div>
</form>
$PocketQuery.renderPocketQueryMacro("ReleaseCalendar", {
'page': $page,
'parameters': {'team':'%', 'year': '%'},
'dynamicload': true
})
<script>
jQuery('#my-pocketquery-form select').change(function() {
var container = jQuery('.pocketquery-dynamic-load[data-query="ReleaseCalendar"]');
var dataIndex = container.data('index');
var data = PocketQuery.getDynamicLoadData(dataIndex);
data.queryParameters = { team: jQuery('#select-team').val(), year: jQuery('#select-year').val() };
PocketQuery.load({
container: container,
data: data
});
var container = jQuery('.pocketquery-dynamic-load[data-query="ReleaseStats"]');
var dataIndex = container.data('index');
var data = PocketQuery.getDynamicLoadData(dataIndex);
data.queryParameters = { team: jQuery('#select-team').val(), year: jQuery('#select-year').val() };
PocketQuery.load({
container: container,
data: data
});
});
</script>