Standalone pager

Is there a way to create a ‘standalone’ pager? I’d like to create a pager which calls a JavaScript function on clicking one of the pager elements.
I tried creating the pager with the following code:

webix_pager = webix.ui({ view: 'pager', container: 'pager_container', size: 50, group: 5, count: 1000 });

Doing this, the following HTML code is created:

`

`

As I understand it, there should be some content within the div-element with the class “webix_pager”, but there isn’t. What am I doing wrong?

And an additional question: Is it possible (after having successfully created the ‘standalone’ pager) to call a JavaScript function with the onClick property within the pager (e.g. clicking the pager button with the number 3, first some data is loaded using AJAX and then this data replaces some other data within a datatable)?

Just add pager.refresh() after initialization

http://webix.com/snippet/79a1981e

Pager normally works in pair with some other component, so it waits for signal that master component is ready, and do not render self just after initialization

You can catch onItemClick event on the pager and use it to control some external component.

In same time you can attach pager to component directly, and control how data loaded in component. Check - http://webix.com/snippet/e8300fe4

Great, that solved my problem. Thank you.

I have another problem. I tried to catch ‘onItemClick’ on the pager, but that does not work. As can be seen in the following snippet, a script error is thrown:

http://webix.com/snippet/03a29ac6

I would really like to use the pager this way, so I’m looking forward for any helpful response :slight_smile:

I can confirm the issue. Pager still expects that there must be a master object.
Fix will be included in the next build
For now, you can try to use the next workaround

http://webix.com/snippet/b9c50e2d

Thank you. This solves the problem with the master object.
But unfortunately the pager still does not do, what I’d like it to. In the above snippet, the ‘onItemClick’ function is not called when I click on a pager-‘button’.
Is there a possibility to make a click on a pager-‘button’ call a function (with the content of the pager-‘button’ as argument - e.g. after clicking the button ‘2’ a function(2) is called)?

I haven’t been able to implement this behavior, so I’d be very happy for some advice.

Try to use the next code - http://webix.com/snippet/eab47a38
We will try to add a more simple way to work with standalone pager in the next build

That looks great. Thank you very much!