Problems, need help? Have a tip or advice? Post it here.
4 posts Page 1 of 1
I've implemented arrow key navigation on a nested pages template (it's for a comic, so you can navigate through the pages easier), using this script;

Code: Select all
<script type="text/javascript">
    $(document).ready(function() {
            document.onkeydown = function()
                    var j = event.keyIdentifier
                    if (j == "Right")
                        window.location = nextUrl
                    else if (j == "Left")
                        window.location = prevUrl           

      $(document).ready(function() {
                    var nextPage = $("#comic_next_page")
                    var prevPage = $("#comic_prev_page")
                    nextUrl = nextPage.attr("href")
                    prevUrl = prevPage.attr("href")

I don't really know javascript at all (really gotta learn it someday though :P ), I found this script and edited it to work with the couch template - and it works really well except for when you get to the first page and navigate back, or on the last page and navigate forward. Obviously there's no page beyond these and so you're taken to a null page. Not so good obviously.

I'd want to either disable forward navigation on the last page/backward navigation on the first page, OR make it return to the listview/archive page when there's no page to navigate to. Whichever is easier :?
How about little change, so page reloads only if nextUrl / prevUrl present?
Code: Select all
if (j == "Right" && nextUrl)
ah, thank you! That did the trick! :D
pitchpurple wrote: ah, thank you! That did the trick! :D

You are welcome :)
4 posts Page 1 of 1

Who is online

In total there are 6 users online :: 1 registered, 0 hidden and 5 guests
(based on users active over the past 5 minutes)

Users browsing this forum: Google [Bot] and 5 guests