Go previous and next in Pager control using left and right arrow keys


<xp:scriptBlock>
	<xp:this.value><![CDATA[var pagerID = "#{id:pager1}"; // <-- Enter the ID of the pager control here which would change based on left / right arrow keys

pagerID = pagerID.replace(/:/g, "\\3A");
dojo.connect(document.body, "onkeydown",
	function(evt) {
		switch (evt.keyCode) {
		case dojo.keys.LEFT_ARROW:
			evt.preventDefault();
			var previousLink = dojo.query("#" + pagerID + " .xspPagerNav.xspPrevious a")[0];
			if (previousLink != null) {
				previousLink.click();
			}
			break;
		case dojo.keys.RIGHT_ARROW:
			evt.preventDefault();
			var nextLink = dojo.query("#" + pagerID + " .xspPagerNav.xspNext a")[0];
			if (nextLink != null) {
				nextLink.click();
			}
			break;
		}
	}
);]]></xp:this.value>
</xp:scriptBlock>
All code submitted to OpenNTF XSnippets, whether submitted as a "Snippet" or in the body of a Comment, is provided under the Apache License Version 2.0. See Terms of Use for full details.
No comments yetLogin first to comment...