josecebe / twbs-pagination

jQuery pagination plugin (bootstrap powered)
http://josecebe.github.io/twbs-pagination/
Other
1.1k stars 401 forks source link

$('.pagination').twbsPagination() function only init once #119

Closed zhangmengxue closed 8 years ago

zhangmengxue commented 8 years ago

I was do some operate on my data. When the data changes,I want to init pagination again,based on the new datas.

This seems impossible. Could help me find out why?

pavelthq commented 8 years ago

66 #86 #11

zhangmengxue commented 8 years ago

@AngeIII I was doing this

$('.pagination').twbsPagination('destory');

but I got an error: Uncaught TypeError: Cannot read property 'apply' of undefined

And I keep seeing the code:

 $.fn.twbsPagination = function (option) {
        var args = Array.prototype.slice.call(arguments, 1);
        var methodReturn;

        var $this = $(this);
        var data = $this.data('twbs-pagination');
        var options = typeof option === 'object' ? option : {};

        if (!data) $this.data('twbs-pagination', (data = new TwbsPagination(this, options) ));
        if (typeof option === 'string') methodReturn = data[ option ].apply(data, args);

        return ( methodReturn === undefined ) ? $this : methodReturn;
    };

The error seems from this...

pavelthq commented 8 years ago

Please make fiddle, of codepen. I will see what is going wrong. Possibly your pagination is not initialized.

Also we have test qunit for destroy method call, so it should be workable.

zhangmengxue commented 8 years ago

well ... the event name is destroy. spelling mistake..

zhangmengxue commented 8 years ago

It's finally work out.Thanks!

SuperChrisliu commented 8 years ago

beautiful girl ! 哈哈

SuperChrisliu commented 8 years ago

Many people have this problem. Why not write to documents.

pavelthq commented 8 years ago

We are ready to receive pull requests. You can update documentation and community will review it.