I'm looking to have a button show up either before or after a view (don't care which), that when clicked would toggle a view between being shown and not shown.
Thanks for any assistance.
Greg
I haven't tested this so not sure it works, but...
1. Make a menu on the page with a button that links to a URL. For the page url type...
javascript.void(0);
2.Then in your code, copy/paste this...
// TYPE THIS PART FOR EACH BUTTON
(function () {
var pageNum = "scene_XX"; //<--page that has the menu and the view to hide
var hideViewNum = "view_XX"; //<--view to hide
var menuViewNum = "view_XX"; //<--menu view that has the button
var buttonText = "Button Text Here"; //<--text on the button
$(document).on("knack-page-render." + pageNum, ((event, page) => {
$("#" + menuViewNum + " a span:contains('"+ buttonText + "')").click(toggleView(hideViewNum));
});
})();
// SHOWS/HIDES THE VIEW - DON'T REPEATEDLY TYPE THIS
function toggleView(viewNum) {
var $view = $("#" + viewNum);
if ($view.is(":visible")) {
$view.hide();
} else {
$view.show();
}
}
/*** NOTE THAT EACH BUTTON ON A SINGLE PAGE NEEDS UNIQUE TEXT FOR THIS TO WORK ***/