Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Prev" and "Next" link breaks when using custom html string in "prev_text" and "next_text" #44

Open
allenfantasy opened this issue Mar 31, 2016 · 0 comments

Comments

@allenfantasy
Copy link

Hi Birke! First of all thank you for your great pagination plugin!

I found an issue which could be a problem if one (like me) wants to customize the pagination appearance.

I passed these options when calling pagination, because I want use "<" and ">" to indicate "prev" and "next":

$("#pagination").pagination(total, {
    prev_text: '<i class="fa fa-angle-left icon-angle-left"></i>',
    next_text: '<i class="fa fa-angle-right icon-angle-right"></i>',
    callback:handlePaginationClick
});

However when I do so, the "prev" and "next" link are broken. After I checked the source code I think I got the reason here:

function paginationClickHandler(evt){
    var links,
        new_current_page = $(evt.target).data('page_id'), // In this line breaks!
        continuePropagation = selectPage(new_current_page);
    if (!continuePropagation) {
        evt.stopPropagation();
    }
    return continuePropagation;
}

Since evt.target would get the DOM element directly listening the event so it points to the <i> element which I inserted before, thus causing the page_id unavailable anymore.

My suggestion is to change evt.target to evt.currentTarget, which is always the DOM element which the event attached to.

I would like to have a PR if needed.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant