Results 1 to 5 of 5

Thread: Multiple book links failure (Ajax Pagination Script)

  1. #1
    Join Date
    Oct 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Multiple book links failure (Ajax Pagination Script)

    1) Script Title:
    Ajax Pagination Script

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...nate/index.htm

    3) Describe problem:
    I believe I have set up my code in the manner specified. However, when I view my page, the link to access another book will not work. It is set up in the following manner (direct copy):

    Code:
    <a href="javascript:development.refresh(web)">Web Development</a> | <a href="javascript:development.refresh(commerce)">E-Commerce</a> | <a href="javascript:development.refresh(members)">Members Area</a> | <a href="javascript:development.refresh(forms)">Custom Forms</a>

    The script is set up the following way (direct copy):
    Code:
    <script type="text/javascript">
               
    var web={} //arbitrary variable to hold page settings for this book
    web.page=["development/web-samples.php"]
    web.selectedpage=0 //set page shown by default (0=1st page)
    			
    var commerce={} //arbitrary variable to hold page settings for this book
    commerce.page=["development/commerce.php"]
    commerce.selectedpage=0 //set page shown by default (0=1st page)
    			
    var members={} //arbitrary variable to hold page settings for this book
    members.page=["development/members.html"]
    members.selectedpage=0 //set page shown by default (0=1st page)
    			
    var forms={} //arbitrary variable to hold page settings for this book
    forms.page=["development/forms.php"]
    forms.selectedpage=0 //set page shown by default (0=1st page)
    			
    var development=new ajaxpageclass.bindpages(web, "pcontent", ["paginate-top", "paginate-bottom"])
               
    </script>
    For the life of me I cannot find the problem even after browsing other forums. I have even tried changing the above code to this format (I changed it to fit my needs, I copied this from another forum):

    Code:
    <script type="text/javascript">
    
    var param=window.location.href.match(/selectpage=(\d+)/i)
    var paramvalue=RegExp.$1
    if (/\d+/i.test(paramvalue)) //if URL parameter contains "?selectpage=integer"
    
    var myajaxbook={} //arbitrary variable to hold page settings for this book
    myajaxbook.page=["external.htm", "external2.htm", "external3.htm", "external4.htm"]
    var param=window.location.href.match(/selectpage=(\d+)/i)
    var paramvalue=RegExp.$1
    if (/\d+/i.test(paramvalue)) //if URL parameter contains "?selectpage=integer"
    myajaxbook.selectedpage=parseInt(paramvalue)
    else
    myajaxbook.selectedpage=0 //set page shown by default (0=1st page)
    
    </script>
    Can anyone help? My page can be accessed at this address: http://www.bluezebradesigns.com/v2/development.php

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Right now each "book" on your page only contains 1 page each- is that how it will look in the end? I ask this because if that's the case, there's little reason to use Ajax Pagination for it, as there's technically nothing to paginate. A better script to use would be Ajax Dynamic Content.

  3. #3
    Join Date
    Oct 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Pages of Pagination

    I didn't finish the page because of getting stumped on the code. Each book will have a good amount of pages eventually. Thank you for the other script, it's something I can use for another project.

    So is the problem because I only have one page per book?

  4. #4
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Yep, there is a bug of the script when your book contains only 1 page. To fix it, inside the .js file, just add the code in red to the following line:

    Code:
    		if (this.pageinfo.page.length==1) //if this book only containe 1 page
    			return
    		var prevlinkoffset=1
    I've updated the script on DD for the correction as well.

  5. #5
    Join Date
    Oct 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up Thank you

    Thank you. Adding the code in the .js file completely fixed the problem. I appreciate your help.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •