I am trying to write a generic pagination utility, a very simplified form is this:
Pagin = function(settings){
var prevSelector = settings.prevSelector || 'a[title="Previous"]',
nextSelector = settings.nextSelector || 'a[title="Next"]';
$(prevSelector).live('click', onPrevNextPage);
$(nextSelector).live('click', onPrevNextPage);
}
There more than a couple of places in the same place that needs pagination. I am trying to reuse it by creating different objects like this:
var gridPagin = new Pagin();
var dialogPagin = new Pagin();
The problem I am facing is, after having 2 objects, clicking on ‘prev’ or ‘next’ the function onPrevNextPage is executed twice.
Is there a way to tell live to trigger only once even though the handler is attached twice?
Thanks,
Chris.
You can detach the previous handler first: