JSFiddle - React, Tailwind, and code Playground

by Zachary Marshall

HTML

<!DOCTYPE html">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Test navigation</title>
</head>
<body>
<div id="content">
     <h3>Test navigation </h3>
  

</div>
<p>
Click goto to page 2. then click the back link and check the console. 
I am trying to get the WIndow command to call the showPage1 function with two parameters from a variable. See the console for output
</p>

<div id="page1" style="display:none">
	<p>page 1</p>
	<button id="toPage2">Go to page 2 </button>
</div>

<div id="page2" style="display:none">

<p>page2 </p>
<button id="toPage1">Go to page 1 </button>
<button id="back">back </button>
</div>

</body>
</html>

JavaScript

$(document).ready(function() {
		navHelper.showPage1("1a","2a");
	});

		
	$('#toPage1').click(function () {
		console.log("event page1  "  );
		navHelper.showPage1("1","2");
	})

	$('#toPage2').click(function () {
		console.log("event page2  "  );
		navHelper.showPage2("3","4");
	})
	
	$('#back').click(function () {
		console.log("event back "  );
		navHelper.back();
	})
	
var navHelper = {		

	showPage1 : function(parma, parmb) {
		console.log("page 1 parms " + parma + " " + parmb);
		$('#page1').show();
		$('#page2').hide();
	},
	
	showPage2 : function(parma, parmb) {
		console.log("page 1 parms " + parma + " " + parmb);
		$('#page1').hide();
		$('#page2').show();
	},	

	back : function(parma, parmb) {
		console.log("back" );
		
		prevPage="showPage1";
		prevParm=['a','b'];		
		/*
		prevParm={
			"a" :'a',
			"b" :'b'
		};
		*/
		
		prevParm1=("a","b");
		prevParm2='a,b';
		prevParm3=("a","b","c");	
	
		//window["navHelper"][prevPage](prevParm);
		//window["navHelper"][prevPage]("a","b"); // works 
		//window["navHelper"][prevPage]["a","b"]; 
		
		
		window["navHelper"][prevPage](prevParm3);
		

	}

}