Call function from custom element

Havig the following custom element:

    <div class="row">
        <div class="col-md-2" if.bind="withSizeLimit">
            <div class="input-group">
                 <input type="text"
                        style="text-align: center;"
                        class="form-control form-control-sm"
                <div class="input-group-append">
                    <button class="btn btn-sm btn-primary" type="button" click.delegate="reload()">
                        <i class="fa fa-refresh" aria-hidden="true"></i>
            <small id="" class="form-text text-muted">Anzahl d. Elemente</small>
        <div class="col-md-10">
          <nav aria-label="pagination">
                <ul class="pagination justify-content-end">
                     <li class="page-item"><a class="page-link" tabindex="-1" click.delegate="previous()"><</a></li>
                     <li class="page-item"><input type="text" class="page-link" style="width: 50px; text-align: center;" change.delegate="reload()" value.bind="page" /></li>
                     <li class="page-item"><a class="page-link" click.delegate='next()'>></a></li>
export class Pagination {
    @bindable withSizeLimit: Boolean;
    @bindable({ defaultBindingMode: bindingMode.twoWay }) page: number = 1;
    @bindable({ defaultBindingMode: bindingMode.twoWay }) size: number = 10;
    @bindable loadFunction;
    @bindable maxPages: number = 10;
    @bindable maxSize: number = 40;

    public constructor(
        private element: Element
    ) {

    attached() {

    public reload() {
        this.loadFunction(, this.size);

    public next() { =;
        if ( >= this.maxPages) = this.maxPages;
        this.loadFunction(, this.size);


    public previous() {
        if ( > 1) {
            this.loadFunction(, this.size);

And the following template snippet:

<pagination with-size-limit.bind="true"
              "LoadIndex(page, size)"

and finally the following class:

public LoadIndex() {
        console.log(page + " " + size);
        if (this.size > 40) this.size = 40;
        if (this.size < 1) this.size = 1;
        if ( > 10) = 10;
        if ( < 1) = 1;
        this.index= [];
        this.Client.getIndex(page, size)
            .then((Index: IndexItem[]) => {
                this.Index =Index;
            .catch(err => {

Now my problem is, that the “next”-button of my custom element doesn’t work. It is always one number behind the “new” value. when I enter the digits directly into the input field, everything works fine. I guess this is a timing problem of calling the “Next()” method from the custom element.
It seems that the function is called before the binded value “page” or “size” is updated.

Can anyone help me?



Thanks for the reply. Unfortunatly this doesn’t solves the problem.

E.g. when I’m on page 2 and click next, then page 2 gets forwarded in request instead of 3.
A console.log in the custom element shows the correct data. In the parent method not :confused:

It seems that the function is triggered before the parent gets informed about the value change.

Sorry. Took a quick stab. Now that I had time to look closer, it appears you need to call:

this.loadFunction(, this.size);

like this:

this.loadFunction({page:, size: this.size});

See Binding Basics > Function References for the details.


Great. So many thanks. That did it for me.

Glad it worked. :grin: