PDA

View Full Version : Multiple book links failure (Ajax Pagination Script)



sunnycali249
10-30-2007, 05:30 PM
1) Script Title:
Ajax Pagination Script

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/ajaxpaginate/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):


<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):


<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):



<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

ddadmin
10-31-2007, 05:56 AM
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 (http://www.dynamicdrive.com/dynamicindex17/ajaxcontent.htm).

sunnycali249
10-31-2007, 02:51 PM
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?

ddadmin
10-31-2007, 08:45 PM
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:


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.

sunnycali249
10-31-2007, 10:42 PM
Thank you. Adding the code in the .js file completely fixed the problem. I appreciate your help.