I was hoping the menu button would allow you to take data on page with button over and fill in the form on the next page, but I don't see it.
I did a workaround with javascript that highlights the corresponding data in the dropdown and moves it to the top of the list. Would love it if there is a more natural way to do this or javascript that actually makes the selection in the dropdown.
Basically on this Unit Details page, I want to take the Unit Address (1137 C St) and populated the dropdown on the Add Petition form when I click Add Petition button.
Any thoughts?
See my javascript below screenshot.
//set global variable to track what unit's detail page we are on when clicking Add Petition
var currentUnitDetail;
//add click event handler to Add Petition button that records the Unit address for the current page
//Will then use the variable to put that unit at the top of the dropdown on the Add Petition Form for ease of selection by staff
$(document).on('knack-scene-render.scene_5', function(event, scene) {
console.log("load unit details page");
$('#view_128').on('click', 'a', function() {
//pick up value from bold heading at top of the page indicating what unit address this is
currentUnitDetail = ($('.kn-detail-body span h1 strong span').text());
});
});
//Move current unit to the top of the dropdown selection
$(document).on('knack-scene-render.scene_85', function(event, scene) {
console.log("in Add Petition = " + currentUnitDetail);
var unitIndex = $('.chzn-results>li:contains("' + currentUnitDetail + '")').index();
console.log(unitIndex);
$('.chzn-results li:eq(0)').removeClass('result-selected');
$('.chzn-results li:eq(' + unitIndex + ')').addClass('result-selected');
$('.chzn-results li:eq(' + unitIndex + ')').insertBefore($('.chzn-results li:eq(0)'));
});