Welcome Guest, Not a member yet? Register   Sign In
point pagination uri-segment to a javascript function rather than a number
#1

[eluser]fiktionvt[/eluser]
I am using the CI pagination class and would like to call a javascript function instead of having it broken up into uri segments so.. for example when I create my page with pagination on it the links look like this

http;//localhost/index/doSomething/10

I want to call a javascript function instead so I would like the links to look something like this.

doSomething(10);

is there anyway to manipulate the links without actually changing the Pagination class in CI? Thanks for the help.
#2

[eluser]mah0001[/eluser]
If you are using JQuery, you can try:
Code:
//option 1: will replace your links with your javascript function
$(document).ready(function() {
    $(".pagination a").each(function(i) {
        $(this).attr("href","[removed]alert("+$(this).text() +")");
    });  
});

//option 2: attach a click event handler
$(document).ready(function() {
    $(".pagination a").each(function(i) {
        $(this).click(function(event){        
            alert($(this).text());
        return false;              
    });

    });  

});




Theme © iAndrew 2016 - Forum software by © MyBB